AnsweredAssumed Answered

How to Fix 'Runtime Error 91' in Component-Insertion Macro?

Question asked by Byron Chiu on Jan 14, 2020
Latest reply on Jan 16, 2020 by Rajat Jain

Hello Community,


I am tweaking a recorded macro that opens an assembly file and adds a component into it (for this post, the macro's capabilities are simplified/censored), setting it at the assembly's origin. The macro gets stuck at "boolstatus = swInsertedComponent.SetTransformAndSolve2(swTransform)", after the transform matrix for the inserted component is set & solved ("Set swTransform = swMathUtil.CreateTransform((TransformDataVariant))").


This error states that "Object variable or With block variable was not set". I read that a macro-recorder does not capture all code, and that some script may be hard-coded and in need of rewriting to make the macro work. However, I cannot find instances of either in the script. I am also using this guide to hopefully find a fix: Object variable or With block variable not set - Visual Basic | Microsoft Docs 


The code is essentially untouched since it was recorded. What specific variable is Solidworks telling me to set, here?