Command Button / Macro

A

Anniebananie

Can anyone tell me how to create the code required to get my command button
to open a directory within c: from my form - I want to link to customer
correspondence issued, mainly word documents. Thanks
 
V

Van T. Dinh

Something like:

Shell """C:\Windows\explorer.exe"" ""C:\Program Files""", vbNormalFocus

or

Application.FollowHyperlink "file:XXC:\Program Files"

(replacing the XX with // as if I put // into above, OE will change it to a
hyperlink address and remove the double-quotes.)
 
K

Ken Sheridan

There are many solutions available to allow you to open the 'File Open'
common dialogue. I use one distributed freely by Bill Wilson which you
simply copy into your Access database as a class module. You can find it at:

http://community.compuserve.com/n/p...yMessages&tsn=1&tid=22415&webtag=ws-msdevapps

A Google search for something like 'Browse for File' will probably throw up
a lot more. Its important to realise that these don't actually open the
file; they return a path to it. With Bill's class module code to open the
dialogue with Word .doc documents as the default file type and
C:\Customers\Correspondence as the opening folder would be like this:

Dim OpenDlg As New BrowseForFileClass
Dim strPath As String
Dim strAdditionalTypes As String, strFileList As String

OpenDlg.DialogTitle = "Select File"
OpenDlg.DefaultType = ".doc"
OpenDlg.InitialDir = "C:\Customers\Correspondence"
strPath = OpenDlg.GetFileSpec
Set OpenDlg = Nothing

You'd then do something with the strPath variable which would contain the
path to the selected file.
 
Top