ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   excel open file macro (https://www.excelbanter.com/excel-programming/299640-excel-open-file-macro.html)

doug

excel open file macro
 
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


Roger Whitehead[_4_]

excel open file macro
 
As in:

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

See OLH for GetOpenFilename Method


--
HTH
Roger
Shaftesbury (UK)


"doug" wrote in message
...
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




Bob Phillips[_6_]

excel open file macro
 
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)

"Roger Whitehead" wrote in message
...
As in:

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

See OLH for GetOpenFilename Method


--
HTH
Roger
Shaftesbury (UK)


"doug" wrote in message
...
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






Roger Whitehead[_4_]

excel open file macro
 
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

"Bob Phillips" wrote in message
...
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)

"Roger Whitehead" wrote in message
...
As in:

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

See OLH for GetOpenFilename Method


--
HTH
Roger
Shaftesbury (UK)


"doug" wrote in message
...
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









All times are GMT +1. The time now is 12:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com