Macro throwing error
- AlexLachance
- Posts: 2174
- Joined: Thu Mar 11, 2021 8:14 am
- Location: Quebec
- x 2353
- x 2008
Macro throwing error
I have a macro which we use to select the level at which a note will grab the property and it's not working anymore, it throws an error 91, object variable not set.
Could anyone help me? I've attached the macro, I'm sure it's something silly.
Basically, we link a note to a part/assembly and then use the macro to select the desired level to pick the property from. When we try to select the desired level, the error appears.
Could anyone help me? I've attached the macro, I'm sure it's something silly.
Basically, we link a note to a part/assembly and then use the macro to select the desired level to pick the property from. When we try to select the desired level, the error appears.
- Attachments
-
- NoteLevelSel.swp
- (108.5 KiB) Downloaded 63 times
Re: Macro throwing error
Are you able to give a list of steps that causes it to fail and show what line it breaks on by clicking Debug?
Re: Macro throwing error
My guess, is that your index is wrong here. (i.e. the value for NumSels doesn't match the allowed values. You told it to grab #3 when there are only 2.)
Select Case swSelMgr.GetSelectedObjectType3(NumSels, -1)
Select Case swSelMgr.GetSelectedObjectType3(NumSels, -1)
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
- AlexLachance
- Posts: 2174
- Joined: Thu Mar 11, 2021 8:14 am
- Location: Quebec
- x 2353
- x 2008
Re: Macro throwing error
Selecting a note, clicking on the macro and trying to select the level from the pop-up window was throwing the error, but it isn't throwing an error as of right now... Seems like it was a case of "Restart the darned program"
- Stefan Sterk
- Posts: 37
- Joined: Tue Aug 10, 2021 2:40 am
- x 51
- x 77
Re: Macro throwing error
I believe the selected component is Ligthweight, which will throw an error when pulling the custom properties.
- AlexLachance
- Posts: 2174
- Joined: Thu Mar 11, 2021 8:14 am
- Location: Quebec
- x 2353
- x 2008
Re: Macro throwing error
I will validate the next time my collegue gets the error, thanks Stefan!Stefan Sterk wrote: ↑Wed Sep 13, 2023 6:03 am I believe the selected component is Ligthweight, which will throw an error when pulling the custom properties.
Re: Macro throwing error
Hey, I think I recognize that form...
Yep, if it happens again, definitely hit "debug" and show which line gets highlighted. If we're lucky the VBA debugger will actually hightlight the problem line.
Yep, if it happens again, definitely hit "debug" and show which line gets highlighted. If we're lucky the VBA debugger will actually hightlight the problem line.
Re: Macro throwing error
If you aren't familiar with the VBA debugger, you should be. It is easy to learn and will be invaluable in sorting these types of issues.
https://www.myonlinetraininghub.com/debugging-vba-code
https://www.myonlinetraininghub.com/debugging-vba-code
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
Re: Macro throwing error
@AlexLachance If you add this code to the location shown in the image, it should solve what @Stefan Sterk was talking about.
Alternatively, the updated SWP file is attached.
Code: Select all
Dim suppression As Integer
suppression = myComp.GetSuppression
If suppression = swComponentLightweight Then
myComp.SetSuppression2 (swComponentFullyResolved)
End If
- Attachments
-
- NoteLevelSel.swp
- (108.5 KiB) Downloaded 51 times
- AlexLachance
- Posts: 2174
- Joined: Thu Mar 11, 2021 8:14 am
- Location: Quebec
- x 2353
- x 2008
Re: Macro throwing error
I think you were the one that developed it for us
I did hit it but I wasn't quite understanding what I was being presented with. I believe it was in this general area, at "first get overall document properties" that was getting highlighted.
Thanks @AlexB for the little tweak, will give it a go! If I get more macro errors, I will definetly try adding a screenshot of the debugger next time.