View Single Post
 
Old 05-07-2009, 11:51 PM
Bird_FAT's Avatar
Bird_FAT Bird_FAT is offline Office 2007
Expert
 
Join Date: Apr 2009
Location: South East
Posts: 271
Bird_FAT is on a distinguished road
Default

Add a command button and use the following code as a starter.
(in this example, I have called the Command Button - 'MyCommandButton' - change the sections of this code to fit with the name of your button [or rename your button])

Code:
Private Sub MyCommandButton_Click()

On Error GoTo Err_MyCommandButton_Click
Dim xlsApp As Excel.Application
Dim xlswkb As Excel.Workbook
Set xlsApp = CreateObject("Excel.Application")
Set xlswkb = GetObject("*FULL_PATH_TO_FILE*")

xlsApp.Application.Run "*FILE_NAME*!*MACRO_NAME*"

xlsApp.Quit

Exit_MyCommandButton_Click:
Exit Sub

Err_MyCommandButton_Click:
MsgBox Err.Description
Resume Exit_MyCommandButton_Click

End Sub
You will, of course, need to add more code in there to do whatever else you need to do - view/print report/query, etc.

Still some work in there for you, but This should give you the start you need
Reply With Quote