VBA TIPS
Get Desktop(MyDocuments, Favorites...) Path

Get the path of the Desktop by SpecialFolders Property of WSH.

The following special folders are available:

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


For example, when you'd like to get AllUsersDesktop, change Desktop to AllUsersDesktop as follows.

WSHShell.SpecialFolders("Desktop") to WSHShell.SpecialFolders("AllUsersDesktop")

Please note, the SpecialFolders property returns an empty string if the requested folder is not available. Place following in the standard module.

Option Explicit

Sub GetDesktopPath()
    Dim WSHShell As Object
    Set WSHShell = CreateObject("Wscript.Shell")
    MsgBox "Your desktop is " & WSHShell.SpecialFolders("Desktop")
    Set WSHShell = Nothing
End Sub



| HOME |
Copyright © cellmasters.net - colo's junk room All Right Reserved
ABOUT
WORKS
THE CELL MASTERS
CONTACT
LINKS
Tips and Information about Microsoft Excel|Masaru Kaji aka Colo