Error 91
Error 91
(OP)
Hello,
I use macro to Close Secondary Window in a part file SW2005.
I found macro in this forum. Thanks. Works fine.
Sub main()
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
SplitterPosition = Part.FeatureManagerSplitterPosition
If SplitterPosition = 1 Then
toggle = 0.5
Else: toggle = 1
End If
Part.FeatureManagerSplitterPosition = toggle
End Sub
But when I am not in a part file program tells me:
“Run-time error 91” “Object variable or With block variable not set”
Something wrong in sentence:
“SplitterPosition = Part.FeatureManagerSplitterPosition”
How can I fix it.
Thank you in advance.
I use macro to Close Secondary Window in a part file SW2005.
I found macro in this forum. Thanks. Works fine.
Sub main()
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
SplitterPosition = Part.FeatureManagerSplitterPosition
If SplitterPosition = 1 Then
toggle = 0.5
Else: toggle = 1
End If
Part.FeatureManagerSplitterPosition = toggle
End Sub
But when I am not in a part file program tells me:
“Run-time error 91” “Object variable or With block variable not set”
Something wrong in sentence:
“SplitterPosition = Part.FeatureManagerSplitterPosition”
How can I fix it.
Thank you in advance.






RE: Error 91
Evan T. Basalik, MCSD
--------------------------------
It's all about prioritization...
RE: Error 91
After i close a document and push signed keybutton i get an error message.
RE: Error 91
If you open a document, then run the macro, does your feature tree window get split as expected?
The reason I ask is the Part.FeatureManagerSplitterPosition call requires an open document.
Evan T. Basalik, MCSD
--------------------------------
It's all about prioritization...
RE: Error 91
I start SW2005, open a document, work inside; program works fine.
I close the document (no opened documents) push keyboard
button and get message.
RE: Error 91
Evan T. Basalik, MCSD
--------------------------------
It's all about prioritization...
RE: Error 91
RE: Error 91
Evan T. Basalik, MCSD
--------------------------------
It's all about prioritization...
RE: Error 91
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
SplitterPosition = Part.FeatureManagerSplitterPosition
If SplitterPosition = 1 Then
toggle = 0.5
Else: toggle = 1
End If
Part.FeatureManagerSplitterPosition = toggle
End
End Sub
RE: Error 91
What version and SP of SW are you running?
Evan T. Basalik, MCSD
--------------------------------
It's all about prioritization...
RE: Error 91
The keybutton I signed is F10; SW2005 SP0.0
Thank you.
RE: Error 91
Evan T. Basalik, MCSD
--------------------------------
It's all about prioritization...
RE: Error 91
When I am in SW only (after I closed all files) and push random button-nothing change.
When I push F5 button I get a Filter bar.
When I push F10 button (I signed for a macro) I get error message. Thanks for your patience.
RE: Error 91
If you run the macro with no documents open, the Set Part = swApp.ActiveDoc will set Part equal to nothing. So the next part of the code will fail and you will get an Error 91. I suggest putting in a line of code something to the order of: If Part = Nothing Then Exit Sub. Put this in just after your Set Part = statement.
Regg
RE: Error 91
RE: Error 91
Opps! Should be: If Part Is Nothing Then Exit Sub
Sorry for the confusion.
Regards,
Regg
RE: Error 91