How to fully define many sketchs in a part-model by api

Hi,

I need to definy a lot of sketches in many parts (with more than one sketch) , because we are maintaining our importmodels.
I have only a little bit experiance with the SWX MAcrorecorder, and little bit more with VBA for Excel.

I've tried it by the macrorecorder for a stepbystep solution.
Later i found this macro example:
2016 SOLIDWORKS API Help - Fully Define Under Defined Sketch Example (VBA)

It works fine for a single sketch, but all the furhter ones stay undefined.
As far as I see, there is no loop for the defining process, but I don't find a solution. For example, if I put the defining process into the loop SWX crashes.
Can anyone help me ho the macro hast to be modified?

Thanks and best regards, Roman

SolidworksApi macros