Help With Toggle Dynamic Highlighting Macro

Ok all

 I am a little stumped. I have what I think should be a very simple macro to toggle the dynamic highlighting on and off.

I like to use it when I need it and not have to deal with it when I don't. My problem is the Preference change will not stay toggled.

 

If I have the highlighting on and then run the macro it toggles it off but only for a couple seconds. As soon as I zoom in

or spin the model the highlighting turns back on.

 

 I have gone as far as adding swApp.RunCommand swCommands_e.swCommands_Options, "" as the end to open the window but then I have to close it manually. It does seem to stay toggled when I do that, but it should work smoother than that.

 

Option Explicit

Dim swApp As SldWorks.SldWorks

Sub main()

Set swApp = Application.SldWorks

If swApp.GetUserPreferenceToggle(swUserPreferenceToggle_e.swEdgesDynamicHighlight) Then
   swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swEdgesDynamicHighlight, False
Else
   swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swEdgesDynamicHighlight, True
End If

End Sub