Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, I am new to VB and cant find how to get my macro to open a file. I know
the location of the file but not the filename, I need the user to pick which file to open. Basically I need the VB to display Excels Open Dialog Box Many thanks in advance |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub test()
Dim F As Variant Dim Myfolder As String Myfolder = "C:\Temp" ChDrive Myfolder ChDir Myfolder F = Application.GetOpenFilename("XL Files (*.xl*), *.XL*") If F = False Then Exit Sub Workbooks.Open F End Sub HTH. Best wishes Harald "PraxisPete" skrev i melding ... Hi, I am new to VB and can't find how to get my macro to open a file. I know the location of the file but not the filename, I need the user to pick which file to open. Basically I need the VB to display Excel's Open Dialog Box Many thanks in advance |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for that Harald, a further development of that is, if all the files
that could be opened required the same password and were to be open as read only, can this be coded in? Thank you again "Harald Staff" wrote: Sub test() Dim F As Variant Dim Myfolder As String Myfolder = "C:\Temp" ChDrive Myfolder ChDir Myfolder F = Application.GetOpenFilename("XL Files (*.xl*), *.XL*") If F = False Then Exit Sub Workbooks.Open F End Sub HTH. Best wishes Harald "PraxisPete" skrev i melding ... Hi, I am new to VB and can't find how to get my macro to open a file. I know the location of the file but not the filename, I need the user to pick which file to open. Basically I need the VB to display Excel's Open Dialog Box Many thanks in advance |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Pete,
Read up on the optional parameters to .Open in the help. NickHK "PraxisPete" wrote in message ... Thanks for that Harald, a further development of that is, if all the files that could be opened required the same password and were to be open as read only, can this be coded in? Thank you again "Harald Staff" wrote: Sub test() Dim F As Variant Dim Myfolder As String Myfolder = "C:\Temp" ChDrive Myfolder ChDir Myfolder F = Application.GetOpenFilename("XL Files (*.xl*), *.XL*") If F = False Then Exit Sub Workbooks.Open F End Sub HTH. Best wishes Harald "PraxisPete" skrev i melding ... Hi, I am new to VB and can't find how to get my macro to open a file. I know the location of the file but not the filename, I need the user to pick which file to open. Basically I need the VB to display Excel's Open Dialog Box Many thanks in advance |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks NickHK,
I've read that and can see that there are parameters for ReadOnly and Password, but, as I understand it, the Open Method requires the FileName which I do not have, the GetOpenFilename does not need the Filename, but does not have parameters for ReadOnly and Password. Its like I need a combination of both. Many thanks. "NickHK" wrote: Pete, Read up on the optional parameters to .Open in the help. NickHK "PraxisPete" wrote in message ... Thanks for that Harald, a further development of that is, if all the files that could be opened required the same password and were to be open as read only, can this be coded in? Thank you again "Harald Staff" wrote: Sub test() Dim F As Variant Dim Myfolder As String Myfolder = "C:\Temp" ChDrive Myfolder ChDir Myfolder F = Application.GetOpenFilename("XL Files (*.xl*), *.XL*") If F = False Then Exit Sub Workbooks.Open F End Sub HTH. Best wishes Harald "PraxisPete" skrev i melding ... Hi, I am new to VB and can't find how to get my macro to open a file. I know the location of the file but not the filename, I need the user to pick which file to open. Basically I need the VB to display Excel's Open Dialog Box Many thanks in advance |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No, very wrong.
GetOpenFilename does just what it says, gets the filename for a file to be opened. It doesn NOT open the file. The filename is F in my code. This F is passed to the Open method in the last line, which is where you add the parameters: Workbooks.Open F, , True, , "Password" HTH. best wishes Harald "PraxisPete" skrev i melding ... Thanks NickHK, I've read that and can see that there are parameters for ReadOnly and Password, but, as I understand it, the Open Method requires the FileName which I do not have, the GetOpenFilename does not need the Filename, but does not have parameters for ReadOnly and Password. Its like I need a combination of both. Many thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. | Excel Discussion (Misc queries) | |||
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. | Setting up and Configuration of Excel | |||
excel 2003 saved file will not open without a blank workbook open | Excel Discussion (Misc queries) | |||
In Excel - Use Windows Explorer instead of File Open to open file | Excel Discussion (Misc queries) | |||
How do I stop Excel from closing the open file each time I open a. | Setting up and Configuration of Excel |