excel open file macro

  • Thread starter Thread starter doug
  • Start date Start date
D

doug

is there a way to open a file in macro where the user
selects the file...like opens the "open file dialogue box"

something like
Sub Macro1()

Workbooks.Open Filename:= _
"C:\Documents and Settings\test.xls _
UpdateLinks:=0
End Sub

but the file name can be chosen by the use?
thanks
 
As in:

myFile = Application.GetOpenFilename("Excel Files,*.xls")

See OLH for GetOpenFilename Method
 
Note that this doesn't open the file, it just returns the full path and name
of the selected file. The file has to be separately opened.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Thats right Bob, my apologies Doug - moe complete code would be:

myFile = Application.GetOpenFilename("Excel Files,*.xls")
workbooks.open myfile
'or
workbooks.open Filename:=myfile

Check out OLH for full syntax

Roger
 

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

Back
Top