• Path for desktop in Windows 2000 (Access 2000/VBA)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Path for desktop in Windows 2000 (Access 2000/VBA)

    Author
    Topic
    #369753

    Hi,
    I have an application that process a data file that the user downloads to his/her desktop. The application was written to look for the file in C:WindowsDesktop. The PCs that this application is located on are being upgraded to Windows 2000 where the desktop location is C:Documents and SettingsDesktop. Since this location varies depending on who has logged on, is there an API call or other way of determining the path of the desktop?

    Thanks,

    Vernon

    Viewing 1 reply thread
    Author
    Replies
    • #582977

      If you have WSH (Windows Scripting Host) installed and active then

      path = CreateObject(“WScript.shell”).SpecialFolders(“Desktop”)

      will return the path to the active user’s Desktop

      Andrew C

      • #583062

        Does the WShell object destroy itself after this call? It’s very space-efficient, but I am so used to the old “Dim an object variable, Set it, and then Set it to Nothing” routine. Could this all be happening implicitly in your code and should not worry about it?

    • #582993

      Besides Andrew’ WSH object solution (which I like), you can also take advantage of the Windows environment varialbe named Userprofile. It returns the root folder for the user. So the desktop folder is:

      %userprofile%Desktop

      Word’s hook into the environment is the Environ() function. Not sure what Access offers.

      • #592277

        hello Kevin

        Can you give me an example of how to use the %userprofile%Desktop to find the path to the Desktop folder. I tried to use it as is, and it gave me a syntax error.

        Thanks

        Wassim compute

        • #592282

          Sure.

          if fso.fileexists(Environ(“UserProfile”) & “DesktopWord.lnk”) then bla bla bla

    Viewing 1 reply thread
    Reply To: Path for desktop in Windows 2000 (Access 2000/VBA)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: