• path variables (VBA)

    Author
    Topic
    #401451

    Does anyone have a list of path variables? For example: There is a variable that will point to the system directory. I think it is %WINROOT% or some such thing like that. I’ve seen various ones, such as to the application data folder of the current user, the current user’s documents and settings folder,etc. Can anyone help me out. thanks.

    I’m wanting to place a file in my user’s documents and settings folder, but need to know what user is logged on, etc. How is this done?

    Viewing 3 reply threads
    Author
    Replies
    • #790782

      Which App? Here are some that are available in Excel:

      Application.Path
      Application.DefaultFilePath
      Application.TemplatesPath
      Application.NetworkTemplatesPath
      Application.StartupPath
      Application.AltStartupPath
      Application.LibraryPath

      For the logged in user, see this thread. Search this forum for other specific default paths you may need. Many of them can be obtained from the Environment String variables, but can be installation dependent and thus not reliable.

    • #790783

      Which App? Here are some that are available in Excel:

      Application.Path
      Application.DefaultFilePath
      Application.TemplatesPath
      Application.NetworkTemplatesPath
      Application.StartupPath
      Application.AltStartupPath
      Application.LibraryPath

      For the logged in user, see this thread. Search this forum for other specific default paths you may need. Many of them can be obtained from the Environment String variables, but can be installation dependent and thus not reliable.

    • #790936

      If Windows Scripting is available to you, the following function might be useful, :

          Function GetSpecialFolderPath(strFolder) As String
          Dim wshShell
              Set wshShell = CreateObject("Wscript.Shell")
              GetSpecialFolderPath = wshShell.SpecialFolders(strFolder)
              Set wshShell = Nothing
          End Function

      If you pass any of the following folder names to the function, the path to that special folder should be returned.

      AllUsersDesktop
      AllUsersStartMenu
      AllUsersPrograms
      AllUsersStartup
      Desktop
      Favorites
      Fonts
      MyDocuments
      NetHood
      PrintHood
      Programs
      Recent
      SendTo
      StartMenu
      Startup
      Templates

      Andrew C

    • #790937

      If Windows Scripting is available to you, the following function might be useful, :

          Function GetSpecialFolderPath(strFolder) As String
          Dim wshShell
              Set wshShell = CreateObject("Wscript.Shell")
              GetSpecialFolderPath = wshShell.SpecialFolders(strFolder)
              Set wshShell = Nothing
          End Function

      If you pass any of the following folder names to the function, the path to that special folder should be returned.

      AllUsersDesktop
      AllUsersStartMenu
      AllUsersPrograms
      AllUsersStartup
      Desktop
      Favorites
      Fonts
      MyDocuments
      NetHood
      PrintHood
      Programs
      Recent
      SendTo
      StartMenu
      Startup
      Templates

      Andrew C

    Viewing 3 reply threads
    Reply To: path variables (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: