Button to open my documents

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created my access database for our customers/sites/jobs and the last
thing I want to do is create a button that will open the correspondence file
- basically link to My Documents. I have tried this a few months ago and am
no further forward - can anyone help?

Thanks, Annie
 
I'm not sure if that what you are asking for, but to open a file in a
specific folder try and use the FollowHyperlink

Dim DocAndPathName As string
DocAndPathName = "c:\My Document\FileName.Doc"
Application.FollowHyperlink DocAndPathName
 
If you want to open the My Documents folder of the current user then you'd
have to find a way to read environment variables. I haven't found a
convenient way to do this yet though, in pure VBA. It would look something
like this:

Shell("explorer.exe %userdrive%%userfolder%")

But unfortunately the Shell command doesn't really pass the String through
the shell as one would expect but instead tries to execute the command
literally.

You could try to get the environment variables from the WScript.Shell-object
but I don't know how portable and reliable that is.

"Anniebananie" schreef:
 
Here you go, I have looked up how to do it the WScript way:

Sub openUserMyDocuments()
Dim objShell As Object
Set objShell = CreateObject("wscript.shell")
Shell "explorer.exe " & objShell.SpecialFolders("MyDocuments")
Set objShell = Nothing
End Sub

"Anniebananie" schreef:
 
Back
Top