Pulling up the standard "File Open" dialog box


Posted by Geoff on June 18, 2001 8:33 AM

What I'd like to do is open a file and I would like to use the standard Microsoft dialog box for that like when you click File, then Open in most programs. Is this possible in VBA? I'd also like to do the same for saving like File, Save As in most programs.

Thanks again in advance,

Geoff

Posted by Dax on June 18, 2001 9:25 AM

Hello Geoff,
There are numerous ways to do this. One way is like this: -
Sub OpenAFileExample()
Dim Fname As String
'Open a file
Fname = Application.GetOpenFilename("File Type,*.xls", , "Open file")

'Save as
Fname = Application.GetSaveAsFilename("Initial Name", , , "Save File As")

End Sub


The code only returns a string which you can then use. I.e. Fname will contain the path name you selected and you could use something like Activeworkbook.SaveAs Fname


HTH,
Dax.



Posted by Geoff on June 18, 2001 12:54 PM

Dax,

Thanks a lot man. That is EXACTLY what I was looking for! I'm very grateful :)

Geoff