Posted to microsoft.public.excel.programming
|
|
Finding a user's My Documents path
Ron,
Thanks for pointing out the caveats. I will be sure to use your code below.
Thanks again,
Bob
"Ron de Bruin" wrote:
"My Documents" in Vista, but I could be wrong about that.
Correct
C:\Users\Ron\Documents
The OP can try this
If I rename my folder to "DocumentsFromRon" the code will work for me Harlan to open the folder
Sub GetSpecialFolder()
'Special folders are : AllUsersDesktop, AllUsersStartMenu
'AllUsersPrograms, AllUsersStartup, Desktop, Favorites
'Fonts, MyDocuments, NetHood, PrintHood, Programs, Recent
'SendTo, StartMenu, Startup, Templates
Dim WshShell As Object
Dim SpecialPath As String
Set WshShell = CreateObject("WScript.Shell")
SpecialPath = WshShell.SpecialFolders("MyDocuments")
'Open folder in Explorer
Shell "explorer.exe " & SpecialPath, vbNormalFocus
End Sub
--
Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm
"Harlan Grove" wrote in message ...
"Gary Keramidas" <GKeramidasATmsn.com wrote...
here' another way
fpath = environ("userprofile") & "\My Documents\"
...
Not guaranteed to work when users change the name of their "My Documents"
folder (which, FWLIW, I've done myself). And I believe it's no longer called
"My Documents" in Vista, but I could be wrong about that.
The only guaranteed correct way to determine a user's "My Documents"
folder's drive/directory path is by going into the Windows Registry, in the
HKCU\Software\Microsoft\Windows\CurrentVersion\Exp lorer\Shell Folders
key, and finding the value of the Personal value-name.
|