Macro not working (recording and running)

Hello everyone,

I make a macro save that I attach to you

' ******************************************************************************
Dim swApp As Object

Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long

Sub main()

Set swApp = _
Application.SldWorks

Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("XXXXX_630S_dechargement_de_650_tendeur_standard-1@xxxxx/63_ensemble_tendeur_palier_(01)-3@XXXXX_630S_dechargement_de_650_tendeur_standard", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.CompConfigProperties4(2, 0, True, True, "Sans moteur", False, False)
Part.ClearSelection2 True
boolstatus = Part.EditRebuild3()
End Sub

 

The problem is that when I  restart this macro it doesn't work, I get an error

"execution error '450'"

Invalid number of arguments or incorrect property assignment

Is this normal?

thank you in advance for your help

 

1 Like

Hello

In most cases, even simple macro recording is not enough.

Apparently, you want to change the configuration of one of the components. But, we need to tell us a little more about the desired goal.

1 Like

Hello

Yes it's normal, you have one too many arguments in your "CompConfigProperties4" function, throw the last False.

Kind regards

1 Like

Thank you for your answers 

By removing the last "False" it works

My goal is only to change a config in an assembly.

What I can't understand is why I just create the macro in Solidworks and Solidworks gives me a fake macro?

 

Yes it's weird, when I do the Solidworks macro recorder comes out almost the same macro as you but by putting "CompConfigProperties5" and not "CompConfigProperties4" and then it works since "CompConfigProperties5" has one more argument.

Kind regards

1 Like

And normally, from the 2019 version of SW, it would be cleaner to take the "CompConfigProperties6" function which still has one more argument...

FYI, the "CompConfigProperties5" function appeared from the 2017 version, it would be interesting to know the evolutions you have followed in the successive installations of Solidworks and if you reinstall the VSTA option each time...

I'm in 2015 version this explains it  maybe :-)

Yes, it's normal that it offers you the "CompConfigProperties4" function but it's weird that it puts one too many arguments in it suddenly!!

This means that this is a point to check on macros coming out of the recorder but as remrem said, "In most cases, even simple, macro recording is not enough.", this is just a help to start macros.

Kind regards

1 Like