Running an Excel macro using VB

  • Thread starter Thread starter Robert Needham
  • Start date Start date
R

Robert Needham

I'm new to VB scripting, and I need to make a script that
will run a macro in excel for me. Does anyone know the
script I can use?

Thanks!
 
When calling procedures, this is the result of my scope testing. To call a worksheet/workbook module you need to have the scope of the procedure as Public. If calling a standard module, you can call a Private procedure

This code assumes you're using VBScript. If not, try to early bind in your code using the proper object classes

dim appExce
set appExcel = GetObject(,"Excel.Application"

dim wb
set wbk = appExcel.Workbooks("Book1.xls"

dim sh
set sht = wbk.Worksheets("Sheet1"

appExcel.Run "Foo" ' This is a standard module
appExcel.Run wbk.Foo ' This is a workbook module
appExcel.Run sht.Foo ' This is a worksheet module

-Brad Vontur
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top