macro button on all documents

  • Thread starter Thread starter Nydia
  • Start date Start date
N

Nydia

i created a form and i password protected it. i had to
put a visual code, so that the user can do spellcheck. i
added a button to the menu bar "RunSpellCheck", this will
allow the user to run the spell check. the problem i am
having is that everytime i open a work document
that "runspellcheck" button is on my menubar. I only want
it on certain documents. I guess, it doesn't hurt to have
it there, but i'm sure there is a way for it to only show
on the documents that i want it to be on. any
suggestions? your help is greatly appreciated :)
 
Nydia,

In each document that you want the button to be visible, use code like that
below. Copy and paste the code into the Thisworkbook object's codemodule,
and modify it to reflect the names of the control and commandbar actually
used.

HTH,
Bernie
MS Excel MVP

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
On Error Resume Next
Application.CommandBars("Command bar name").Controls("Control
Name").Visible = True
End Sub

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
On Error Resume Next
Application.CommandBars("Command bar name").Controls("Control
Name").Visible = False
End Sub
 
Back
Top