Running Excel Macro from VB6

  • Thread starter Thread starter Rick Griffith
  • Start date Start date
R

Rick Griffith

I've got a VB6 program that runs an excel 2000 macro fine
if the spreadsheet is opened by user before running the VB
program. If user doesn't open the spreadsheet an error
occurs.

Is there a way to eliminate need for user to open the
spreadsheet?
 
Rick,

The workbook will have to be opened to run the macro, whether your user does
it or whether you do from your VB6 app.

If you want some code on opening the workbook, try something like

Set xlApp = CreateObject("Excel.Application")
If Not xlApp Is Nothing Then
xlApp.Workbooks.Open "D:\Bob\My Documents\My
Spreadsheets\Lastcount.xls"
xlApp.Visible = True
xlApp.Run "LastCount.xls!Test"
xlApp.Quit
End If
 
Back
Top