Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Anyone know how how to grey out a macro icon?

Status
Not open for further replies.

MrMiller

Aerospace
Jan 30, 2004
54
I would like to grey out my macro icons when they are unavailable to certain areas? For example if I have an icon that performs assembly operations I would like it greyed out during drawings. I know I could just put it in the assembly toolbar but would like to do this instead so I can group all our custom macro icons in one toolbar.

Anyone have an answer?
 
Replies continue below

Recommended for you

Enhancement Request

Regards,

Scott Baugh, CSWP [borg2]
CSWP.jpg

faq731-376
 
You could create groups of your macros, Assembly, Part, etc, then just include those in their respective toolbars.

[cheers] from (the City of) Barrie, Ontario.

[lol] Everyone has a photographic memory. Some just don't have film. [lol]
 
You could also do a check when the macro starts to determine if the current active document is what it is suppose to be. If not, have a gentle error message tell the user that the macro cannot be run, then end the macro.
 
If your macro is specific to a document type, add a few lines of code to the beginning of your macros to detect document type. This is prudent in all SW API programming.
 
An example of testing for document type would be:

Sub main()

Set swApp = CreateObject("SldWorks.Application")
Set Doc = swApp.ActiveDoc

If ((Doc Is Nothing) Or (Not (Doc.GetType Eqv swDocDRAWING))) Then
Msg = "A drawing document must be active to use this command!"
LongStatus = swApp.SendMsgToUser2(Msg, swMbWarning, swMbOk)
End

Else
Doc.PrintDirect

End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor