Running Macro from objApp Application object

  • Thread starter Thread starter Lance Hoffmeyer
  • Start date Start date
L

Lance Hoffmeyer

SO, if I create an application obhect, objExcelApp
how would I run a macro from the workbook
macro.xls called addnewsheet?

macro.xls!addnewsheet






Sub CreateExcel()
Set objExcelApp = GetObject(,"Excel.Application")
objExcelApp.Visible = True
objExcelApp.Workbooks.Add
End Sub


Lance
 
Lance said:
SO, if I create an application obhect, objExcelApp
how would I run a macro from the workbook
macro.xls called addnewsheet?

macro.xls!addnewsheet






Sub CreateExcel()
Set objExcelApp = GetObject(,"Excel.Application")
objExcelApp.Visible = True
objExcelApp.Workbooks.Add
End Sub


Lance

//this is in C#

objExcelApp.GetType().InvokeMember("Run",
System.Reflection.BindingFlags.Default |
System.Reflection.BindingFlags.InvokeMethod,null, objExcelApp, new
Object[]{ "'macro.xls'!addnewsheet.addnewsheet"});
 

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