Runs a macro from a project file.
.NET Syntax
Visual Basic (Declaration) | |
---|
Function RunMacro2( _
ByVal FilePathName As System.String, _
ByVal ModuleName As System.String, _
ByVal ProcedureName As System.String, _
ByVal Options As System.Integer, _
ByRef Error As System.Integer _
) As System.Boolean |
Visual Basic (Usage) | |
---|
Dim instance As ISldWorks
Dim FilePathName As System.String
Dim ModuleName As System.String
Dim ProcedureName As System.String
Dim Options As System.Integer
Dim Error As System.Integer
Dim value As System.Boolean
value = instance.RunMacro2(FilePathName, ModuleName, ProcedureName, Options, Error) |
Parameters
- FilePathName
- Path and filename of the project file containing the macro
- ModuleName
- Name of the module in the macro
- ProcedureName
- Name of the procedure in the module
- Options
- Option as defined swRunMacroOption_e (supports VBA macros only)
- Error
- Error as defined by swRunMacroError_e (supports VBA macros only)
Return Value
True if macro runs, false if not
Example
Visual Basic for Applications (VBA)
- Create two VBA macros using the following code samples.
- Store RunMacroSub.swp in c:\test.
- Run RunMacro.swp.
'----------------------------
' RunMacro.swp
'---------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim boolstatus As Boolean
Sub main()
Set swApp = Application.SldWorks
Dim runMacroError As Long
boolstatus = swApp.RunMacro2("c:\test\RunMacroSub.swp", "RunMacroSub1", "main", swRunMacroUnloadAfterRun, runMacroError)
End Sub
'---------------------------------------
' RunMacroSub.swp
'---------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Sub alternate()
Set swApp = Application.SldWorks
swApp.SendMsgToUser "RunMacroSub1:alternate() called."
End Sub
Sub main()
Set swApp = Application.SldWorks
swApp.SendMsgToUser "RunMacroSub1:main() called."
End Sub
Running a C# DLL from VBA
boolstatus = Me.swApp.RunMacro2('C:\Test\CSharpMacro\SwMacro\bin\Release\CSharpMacro.dll',
'', 'Main', swRunMacroOption_e.swRunMacroDefault, runMacroError)
Remarks
See Also
Availability
SOLIDWORKS 2009 FCS, Revision Number 17.0