I don’t understand why my If/Then doesn’t work when booQuestion is True. I stepped through and booQuestion is True but won’t execute the debug.print statement:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim booQuestion As Boolean
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
booQuestion = swModel.GetSaveFlag
If booQuestion = True Then
Debug.Print “Needs to be saved.”
End If
Ready to start learning the SolidWorks API? Sign up for FREE membership here.Keep up with new videos, macros, and training events by joining our mailing list:
Hi Keith,
I don’t understand why my If/Then doesn’t work when booQuestion is True. I stepped through and booQuestion is True but won’t execute the debug.print statement:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim booQuestion As Boolean
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
booQuestion = swModel.GetSaveFlag
If booQuestion = True Then
Debug.Print “Needs to be saved.”
End If
End Sub
This line is redundant:
If booQuestion = True Then
It is like saying, “If True is True Then do X”. Which should still work, but in this case the program is confused. So simply use this instead:
If booQuestion Then