Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting FileOpen directory

Status
Not open for further replies.

neilabbott

Technical User
Mar 11, 2003
19
With a current job record in Access I use VBA code to do a FileOpen operation in Word (eg show all myjobnumber*.doc).
All the documents are on a network drive.
No matter what I do with hard coding the required directory in VBA, the wdDialogFileOpen operation always pops up in the last directory the user used.
I assume there is some other point within 'Office' that overrides my code and throws up the 'last used' directory.

Is there a way round this?
Neil

 
Hi Neil,

This can be a real pain. There is a global default path (held in the registry and available under Tools > Options > Locations) and a current session default path. When a document is opened via the dialog, the path used becomes the 'session' path (but not the 'global' one). When the 'global' path is changed it also overwrites the session path.

Now, there is another (better) way to do this but I can't bring it to mind. Perhaps someone else can. Meanwhile you should be able to make your process work by changing the global default before displaying the dialog. Immediately before showing the dialog add

Code:
appWord.Options.DefaultFilePath(Path:=wdDocumentsPath) = "D:\My Documents"

.. changing 'appWord' to your Word Application object, and using your own desired path.

Enjoy,
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top