full path to My document and Desktop...


  1. Posts : 10
    windows 7
       #1

    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 Computer


  2. Posts : 71,977
    64-bit Windows 11 Pro for Workstations
       #2

    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 Computer


  3. Posts : 10
    windows 7
    Thread Starter
       #3

    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 Computer


  4. Posts : 71,977
    64-bit Windows 11 Pro for Workstations
       #4

    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 Computer


  5. Posts : 10
    windows 7
    Thread Starter
       #5

    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 Thumbnails Attached Thumbnails full path to My document and Desktop...-windows7_save_error.jpg  
      My Computer


  6. Posts : 71,977
    64-bit Windows 11 Pro for Workstations
       #6

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


    Use:

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

    Instead of:

    OUTPATH = "c:\users\%UserProfile%\Desktop\" & FName & ".xlsx"
      My Computer


  7. Posts : 10
    windows 7
    Thread Starter
       #7

    full path to My document and Desktop...


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

    and it still did not like it.
    Attached Thumbnails Attached Thumbnails full path to My document and Desktop...-more_windows7_save_error.jpg  
      My Computer


  8. Posts : 71,977
    64-bit Windows 11 Pro for Workstations
       #8

    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 Computer


  9. Posts : 10
    windows 7
    Thread Starter
       #9

    full path to My document and Desktop...


    Hi. Please see the attached *.bas module.
    full path to My document and Desktop... Attached Files
      My Computer


  10. Posts : 71,977
    64-bit Windows 11 Pro for Workstations
       #10

    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 Computer


 

  Related Discussions
Our Sites
Site Links
About 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 02:02.
Find Us