ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running Macro from objApp Application object (https://www.excelbanter.com/excel-programming/308232-running-macro-objapp-application-object.html)

Lance Hoffmeyer

Running Macro from objApp Application object
 
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

tommy

Running Macro from objApp Application object
 
Lance Hoffmeyer wrote:

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"});



All times are GMT +1. The time now is 05:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com