Folder Path

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top