Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / April 2008

Tip: Looking for answers? Try searching our database.

Reset Custom Button on toolbar

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Josh O. - 15 Apr 2008 20:23 GMT
I am running the below code...is it possible to have reset the two buttons I
added in the Sub Menu_Item macro to the active file name after a "Save As".  
I keep getting an error saying that "The macro 'OriginalFileName!InsertLine'
cannot be found."

Private Sub Workbook_Open()
   Call MenuBar_Item
   Call DoF
End Sub

Private Sub MenuBar_Item()
   Call MenuBar_Item_Delete
   With Application.CommandBars("Standard")
       With .Controls.Add(Type:=msoControlButton, ID:=2, Temporary:=True _
           , Before:=1)
           .Style = msoButtonIcon
           .Caption = "&Spell Check"
           .TooltipText = "Run Spell Check"
           .OnAction = ThisWorkbook.Name & "!SpellCheck"
           .Tag = "SpellCheck"
       End With
       With .Controls.Add(Type:=msoControlButton, ID:=295, Temporary:=True _
           , Before:=2)
           .Style = msoButtonIcon
           .Caption = "&Insert Formated Line"
           .TooltipText = "Run Insert Formated Line"
           .OnAction = ThisWorkbook.Name & "!InsertLine"
           .Tag = "InsertLine"
       End With
   End With
End Sub

Private Sub MenuBar_Item_Delete()
   On Error Resume Next
   Application.CommandBars.FindControl(Tag:="SpellCheck").Delete
   Application.CommandBars.FindControl(Tag:="InsertLine").Delete
   On Error GoTo 0
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
   Call UndoDoF
End Sub

Private Sub DoF()
   With Application
       .OnKey "{F7}", "SpellCheck"
       .OnKey "{F12}", "InsertLine"
   End With
End Sub

Private Sub UndoDoF()
   With Application
       .OnKey "{F7}"
       .OnKey "{F12}"
   End With
End Sub
Josh O. - 15 Apr 2008 20:31 GMT
Nevermind...I found the error.  I missed the line: "ThisWorkbook.Name & "
after the OnAction.

> I am running the below code...is it possible to have reset the two buttons I
> added in the Sub Menu_Item macro to the active file name after a "Save As".  
[quoted text clipped - 52 lines]
>     End With
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.