View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default 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.
.