How to set the default path that is used for opening files (in macro VBA)?
Posted by Krumpin on January 18, 2001 4:44 AM
I am working on an MS Excel application. I have written a macro instruction that should show the standard OpenFile box for opening files. Thats OK, but I want this box to be prepared (set up) to open files in specific directory (different than that set up in standard Excel settings - Tools/Options/General Tab, "Default File Location").
I have tried to use properties Application.DefaultFilePath. But there is no suggestion in VBA Help how to use it. When I write e.g. Application.DefaultFilePath = "C:\directory, it doesnt work. It only set up C:\dir as a value of a variable (it can be shown by: MsgBox "The current default file path is " & Application.DefaultFilePath).
Do you anybody know what the matter of the problem is?
The example of VBA code (but it doesnt work correctly):
Application.DefaultFilePath = "C:\dir"
newTextFile = Application.GetOpenFilename("Text Files, *.txt")