×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Anyone know how how to grey out a macro icon?

Anyone know how how to grey out a macro icon?

Anyone know how how to grey out a macro icon?

(OP)
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?

RE: Anyone know how how to grey out a macro icon?

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

from (the City of) Barrie, Ontario.

Everyone has a photographic memory. Some just don't have film.

RE: Anyone know how how to grey out a macro icon?

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.

RE: Anyone know how how to grey out a macro icon?

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.

RE: Anyone know how how to grey out a macro icon?

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources