StarrRider
Mechanical
- Sep 15, 2002
- 151
Hi Guys
A friend of mine called attention to a minor problem he is having with some of my macros. The macros are assigned to the numeric keypad and when the SW Browser is opened inside of SW an error message is generated if the keypad is used. Here is the offending section of code:
' *******************************************************
Const swMbWarning = 1
Const swMbOk = 2
Dim swApp As Object
Dim Model As Object
Sub main()
Set swApp = CreateObject("SldWorks.Application"
Set Model = swApp.ActiveDoc
If Model Is Nothing Then
swApp.SendMsgToUser2 "A file must be opened before these keys work.", swMbWarning, swMbOk
Exit Sub
End If
' the remainder of the code
End Sub
This error message is only supposed to be displayed if there is not a file open in SW. Instead – the error message is displayed while the SW Browser is active - even if there is an Active Document open in SW. I would be willing to bet the same thing happens when any other add-in (like Cosmos) is active.
One solution would be to eliminate the error message. This does allow the keys to operate normally but a better solution would be to test to see if a SW or an Add-In was active. I did do a fast search of the API but I came up with nothing.
Does anybody else have any suggestions or ideas?
Lee
Consciousness: That annoying time between naps.
A friend of mine called attention to a minor problem he is having with some of my macros. The macros are assigned to the numeric keypad and when the SW Browser is opened inside of SW an error message is generated if the keypad is used. Here is the offending section of code:
' *******************************************************
Const swMbWarning = 1
Const swMbOk = 2
Dim swApp As Object
Dim Model As Object
Sub main()
Set swApp = CreateObject("SldWorks.Application"
Set Model = swApp.ActiveDoc
If Model Is Nothing Then
swApp.SendMsgToUser2 "A file must be opened before these keys work.", swMbWarning, swMbOk
Exit Sub
End If
' the remainder of the code
End Sub
This error message is only supposed to be displayed if there is not a file open in SW. Instead – the error message is displayed while the SW Browser is active - even if there is an Active Document open in SW. I would be willing to bet the same thing happens when any other add-in (like Cosmos) is active.
One solution would be to eliminate the error message. This does allow the keys to operate normally but a better solution would be to test to see if a SW or an Add-In was active. I did do a fast search of the API but I came up with nothing.
Does anybody else have any suggestions or ideas?
Lee
Consciousness: That annoying time between naps.