Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Macros

Status
Not open for further replies.

SpyShaft

Programmer
Mar 30, 2002
1
GB
HI. I would like to run an Excel Macro after I have exported Data from Visual Basic. Maybe call the Macros from a external file.?

Any Ideas.

Thanks
Richard.
 
With VB, go to Project, References. Look for 'Microsoft Excel blah blah blah'. Select that. Now you have access to basically running your own version of Excel in the background.

Now you have access to these commands
Code:
Private Sub Form_Load()
  Dim ExcelApp As New Excel
  Set ExcelApp = New Excel
  
  Excel.Workbooks.Open "filename"
  Excel.Application.Run "macro"
  Excel.Application.SaveWorkspace
  Excel.Workbooks.Close
  
  Set Excel = Nothing
  
End Sub
I have no idea what works and doesn't. I would be appreciative if you revisit the site to mention what could be corrected. But I hope this is a good start.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top