Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I write an Excel macro to open a file using the CommonDial.
I am writing a macro. I have one spreadsheet open. I want the user to be
prompted to open a second spreadsheet by opening the Open Dialog Box and having the user click on the file they want to open. VB has a ShowOpen command, but I am having trouble using it with excel. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I write an Excel macro to open a file using the CommonDial.
The code would look like this:
'Prompt user for Excel file to open MsgBox "Choose the data file for this report from the following dialog.", vbOKOnly Application.Dialogs.Item(xlDialogOpen).Show You would attach this code to either a button or command bar, etc. For example, you could do this: Sub OpenFile 'Prompt user for Excel file to open MsgBox "Choose the data file for this report from the following dialog.", vbOKOnly Application.Dialogs.Item(xlDialogOpen).Show End Sub Then right click on the toolbar and choose the Forms toolbar. From there choose the command button. When you draw the button on the screen it will ask you to assign a macro. Choose your OpenFile macro. tod -----Original Message----- I am writing a macro. I have one spreadsheet open. I want the user to be prompted to open a second spreadsheet by opening the Open Dialog Box and having the user click on the file they want to open. VB has a ShowOpen command, but I am having trouble using it with excel. . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I write an Excel macro to open a file using the CommonDial.
In Excel,
Dim fName as Variant fName = Application.GetOpenFileName( _ FilterIndex:="Excel Files (*.xls),*.xls") if fName = False then msgbox "You hit cancel" exit sub else set wkbk = workbooks.Open(fName) End if -- Regards, Tom Ogilvy "Lynn" wrote in message ... I am writing a macro. I have one spreadsheet open. I want the user to be prompted to open a second spreadsheet by opening the Open Dialog Box and having the user click on the file they want to open. VB has a ShowOpen command, but I am having trouble using it with excel. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how can i open the write protected excel file? | Excel Discussion (Misc queries) | |||
Saving a copy of excel file in macro but have it auto write | Excel Worksheet Functions | |||
HOW TO OPEN A WRITE PROTECTED FILE (USB) | Excel Discussion (Misc queries) | |||
Write Procedure With Logic Test To Open File From Given Directory | Excel Programming | |||
Open file to write and read at the same time | Excel Programming |