specifing default folder with GetOpenFilename

B

Brian

I'm am using the GetOpenFilename method to allow a user to
pick a spreadsheet to open. This is to by-payss the
enable/disable macro option. I want to start the user in
a specific network folder(instead of their
defaultfilepath). Is there a way to do this?

I have tried the Application.DefaultFilePath = ("xxxx")
but this only changes the default folder the next time the
user accesses the the system and not the current instance.

Thanks,

Brian.
 
R

Ron de Bruin

I will save your default folder first to set it back at the end

Sub test()
Dim SaveDriveDir As String
Dim TheFileName As Variant
SaveDriveDir = CurDir
ChDrive "C"
ChDir "C:\Data"
TheFileName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls")

MsgBox "your code"

ChDrive SaveDriveDir
ChDir SaveDriveDir
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