Macro execution problem in macro?

Hello

 

I want to schedule a macro to start through a macro loop, but SOLIDWORKS gives me an error message that it can't open my second macro file.

Main Macro Name: Execution_propriete_automatique_en_boucle

Windows Name: Running Automatic Property in Loop.swp

Secondary Macro Name: propriété_pièce

Windows name: PROPRIETE_PIECE.swp

Macro principle:

Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2


Sub main()
Dim bRet As Boolean
Dim swErrors As Long
Dim swWarnings As Long
Dim RetVal As String

Set swApp = Application.SldWorks
    
Do
        
'Retrieves the active document in SW
        
Set swModel = swApp.ActiveDoc
If Not swModel Is Nothing Then
            
Macro Second Activation
RetVal = swApp.RunMacro("D:\CAO\DOCUMENT MODEL\MACRO\AUTO-PROPERTY\PROPRIETE_PIECE, - PROPRIETE_PIECE.swp", "propriété_pièce", "Main")
            
'Records the active document silently
bRet = swModel.Save3(swSaveAsOptions_Silent, swErrors, swWarnings)
            
'Closes the active document
swApp.CloseDoc swModel.GetPathName
        
End If
    
'looping until there is no longer a file open in SW
Loop While Not swModel Is Nothing
End Sub
 

Second Macro attachment.

Kind regards


propriete_piece.swp

Runmacro2 test:

http://help.solidworks.com/2013/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.ISldWorks~RunMacro2.html

EDIT: Runmacro is now deprecated

Hello

Try the attached method.

See you


propriete_piece.swp