Folder Path

  • Thread starter Thread starter Maldo
  • Start date Start date
M

Maldo

I would like to use this procedure to determine the "My Documents" folder
path for the user currently logged into any given PC.

It always returns "C:\Documents and Settings\fby0776\My Documents" when I
test it on my PC. This is actual result I would like to achieve for each
user on their PC. Will this code guarantee to always return the "My
Documents" folder path? I intend to feed the result into a variable to use
elsewhere. Please Advise

Sub ShowFolderInfo()

Dim fs, d, f, s, folderspec

folderspec = "C:"

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
s = UCase(f.Path) & vbCrLf
s = s & "Created: " & f.DateCreated & vbCrLf
s = s & "Last Accessed: " & f.DateLastAccessed & vbCrLf
s = s & "Last Modified: " & f.DateLastModified
MsgBox s, 0, "File Access Info"

End Sub
 
Back
Top