Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: full path to My document and Desktop...

16 Dec 2013   #1
dtvonly

windows 7
 
 
full path to My document and Desktop...

Hi. I want to know the full path to documents and desktop in windows 7, and I want to full path for all users. the problem is when I look in my c:\users\public there is no documents nor is there a desktop folder. I don't want to specify a user's name to a path since my application (.exe) can and will be used on any computer.

To summarize:

I need: C:\Users\Pulbic\Desktop or C:\Users\Pulbic\Documents

I don't need: C:\users\john_doe\Desktop or C:\users\john_doe\Documents

Please advise.


My System SpecsSystem Spec
.
16 Dec 2013   #2
Brink

64-bit Windows 10 Pro
 
 

Hello dtvonly, and welcome to Seven Forums.

You could use the %UserProfile% variable for this. It's a shortcut for the "C:\Users\(user-name)" path of any user.

For example, use this path below to open the current user's desktop folder.

%UserProfile%\Desktop

Hope this helps,
Shawn
My System SpecsSystem Spec
16 Dec 2013   #3
dtvonly

windows 7
 
 
full path to My document and Desktop...

Hi brink. I tried:
c:\users\%userprofile%\Desktop\"myfile.text"

Windows 7 didn't like that.

Please provide full path to public desktop or Document.

Thank you
My System SpecsSystem Spec
.

16 Dec 2013   #4
Brink

64-bit Windows 10 Pro
 
 

No worries. You just didn't use it properly. You would use this instead for that path. This is for the user's personal Desktop folder location though, and not the Public folder location.

%UserProfile%\Desktop\myfile.text

OR

(If spaces in path)
"%UserProfile%\Desktop\my file.text"
My System SpecsSystem Spec
16 Dec 2013   #5
dtvonly

windows 7
 
 
full path to My document and Desktop...

Hi. Ok here is my full path in VB6:

OUTPATH = "c:\users\%UserProfile%\Desktop\" & FName & ".xlsx"
where FName = "myfile"

so the full file name is myfile.xlsx

Please see attached image for error message. Please advice. Thank.


Attached Images
full path to My document and Desktop...-windows7_save_error.jpg 
My System SpecsSystem Spec
16 Dec 2013   #6
Brink

64-bit Windows 10 Pro
 
 

%UserProfile% = C:\Users\current-user-name


Use:

OUTPATH = "%UserProfile%\Desktop\" & FName & ".xlsx"

Instead of:

OUTPATH = "c:\users\%UserProfile%\Desktop\" & FName & ".xlsx"
My System SpecsSystem Spec
16 Dec 2013   #7
dtvonly

windows 7
 
 
full path to My document and Desktop...

Hi. I tried OUTPATH = "%UserProfile%\Desktop\" & FName & ".xlsx"

and it still did not like it.


Attached Images
full path to My document and Desktop...-more_windows7_save_error.jpg 
My System SpecsSystem Spec
16 Dec 2013   #8
Brink

64-bit Windows 10 Pro
 
 

Something is still not correct with the code since the path it shows in the error still has "C:\Users\dvu\Documents" in front of the "%UserProfile%" variable.
My System SpecsSystem Spec
16 Dec 2013   #9
dtvonly

windows 7
 
 
full path to My document and Desktop...

Hi. Please see the attached *.bas module.


Attached Files
File Type: zip Save2Excel.zip (921 Bytes, 2 views)
My System SpecsSystem Spec
16 Dec 2013   #10
Brink

64-bit Windows 10 Pro
 
 

I'm afraid that I'm not familiar enough with working with Excel and .bas modules to help much on that.

Hopefully someone better at coding will be able to know.


Code:
Attribute VB_Name = "ExcelSave"
 
Option Explicit
 
'Const VK_MENU = 18                 ' Alt key
Const VK_MENU = 11                  ' Ctrl key
Const VK_SNAPSHOT = 44
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2
 
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
'
'   this routine saves all collected data to MS Excel
'
Public Sub Save_B4_Exit()
 
Dim FName As String
Dim test_str1 As String
Dim test_str2 As String
Dim test_str3 As String
Dim OUTPATHNETWORK As String
Dim OUTPATHNETWORK_BAK As String
Dim OUTPATHLOCAL As String
Dim OUTPATH As String
 
xlWS.Cells(1, 1).ColumnWidth = 20
xlWS.Cells(1, 1).HorizontalAlignment = xlCenter
Call Write2Excel(1, 1, "Test Location: NH" & Test_location)
 
test_str1 = Form1.Combo3.List(Form1.Combo3.ListIndex) & "_"
test_str2 = Form1.Text1.Text & "_"
test_str3 = "NH" & Test_location
FName = test_str1 & test_str2 & test_str3
 
'OUTPATH = Form1.Text5.Text & FName & ".xlsx"                       '   use this with MSOffice 2007/2010. Mostly for Windows 7.
'OUTPATH = "C:\" & FName & ".xlsx"                                  '   use this with MSOffice 2007/2010
'OUTPATH = "C:\" & FName & ".xls"                                   '   use this with MSOffice 2003
 
OUTPATH = "%UserProfile%\Desktop\" & FName & ".xlsx"                 '   Windows 7 desktop
 
OUTPATHNETWORK = "S:\QUALITY CONTROL LOG\Light Tube Testing\" & FName & ".xlsx" ' use this with MSOffice 2007 to network path
'OUTPATHNETWORK = "S:\" & FName & ".xlsx"
'OUTPATHNETWORK_BAK = "S:\QUALITY CONTROL LOG\Light Tube Testing\" & FName & "_bak.xlsx"
 
xlApp.DisplayAlerts = False
xlWB.SaveAs OUTPATH
xlWB.SaveAs OUTPATHNETWORK
 
If (Exit_button) Then
    xlWB.Close (True)
    xlApp.Quit
    Set xlWS = Nothing
    Set xlWB = Nothing
    Set xlApp = Nothing
End If
 
End Sub
My System SpecsSystem Spec
Reply

 full path to My document and Desktop...




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Open a new window with "full path" instead of Search Results\"Path"
How can I make it such that in Search Results, when I open a folder in a new window (by right-clicking a file), I will be directed to a window with the "full path" displayed in the address bar, instead of Search Results\"Path" or Search Results>"Path"? Edit: "Right-click -> open file location"...
General Discussion
How to show the full path of the shared folders?
How to show the full path of the shared folders? For example, I have shared the h folder which is stored on the D drive of the P1 Computer. What I wanted is to show the full path of the shared folder such that it (shared folder) appears as (screenshot is attached): \\P1\Local Disk...
Network & Sharing
Trying to Find Document Path
I have MS Office 2003. I have looked in the Options trying to find where I can change my path to my documents, it is incorrect since I moved them. I felt sure it was there but I can't find it. Where should they be? Thanks,
Microsoft Office
Excel document linking broken due to new documents path in Win7
Hi all, I've recently moved from XP to 7 and realized that due to the change in path to my documents folder any references from one Excel workbook to another no longer work because the reference is to an absolute path and expects the "C:\Document and Settings\..." path rather than "C:\users\..."...
Microsoft Office
Show full path in jumplists
Hi, Thanks to everyone who helped with my previous question! New question: Is there a way to get jumplists (especially Windows Explorer) to show the full path of each folder, or at least enough to differentiate similarly named folders? For instance, at work, every project I work on gets...
Performance & Maintenance
how to find full path name
New to W7 (4 days) On transferring files to new computer, one quicken file did not load in registry. Quicken tech support told me to print the full path of the file QWAPP.DLL in "run." How do I find the full path?
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 17:38.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App