_Application.ExecuteExcel4Macro Method
Runs a Microsoft Excel 4.0 macro function, and then returns the result of the function. The return type depends on the function.
Namespace: Microsoft.Office.Interop.Excel
Assembly: Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)
Syntax
'Declaration
Function ExecuteExcel4Macro ( _
String As String _
) As Object
'Usage
Dim instance As _Application
Dim String As String
Dim returnValue As Object
returnValue = instance.ExecuteExcel4Macro(String)
Object ExecuteExcel4Macro(
string String
)
Parameters
String
Type: System.StringRequired String. A Microsoft Excel 4.0 macro language function without the equal sign. All references must be given as R1C1 strings. If String contains embedded double quotation marks, you must double them. For example, to run the macro function =MID("sometext",1,4), String would have to be "MID(""sometext"",1,4)".
Return Value
Type: System.Object
Remarks
The Microsoft Excel 4.0 macro isn't evaluated in the context of the current workbook or sheet. This means that any references should be external and should specify an explicit workbook name. For example, to run the Microsoft Excel 4.0 macro "My_Macro" in Book1, you must use "Book1!My_Macro()". If you don't specify the workbook name, this method fails.