Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Reset Custom Button on toolbar

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 _
, Befo=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 _
, Befo=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:="SpellChe ck").Delete
Application.CommandBars.FindControl(Tag:="InsertLi ne").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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Reset Custom Button on toolbar

Nevermind...I found the error. I missed the line: "ThisWorkbook.Name & "
after the OnAction.

"Josh O." wrote:

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 _
, Befo=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 _
, Befo=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:="SpellChe ck").Delete
Application.CommandBars.FindControl(Tag:="InsertLi ne").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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding custom images to a button on custom toolbar Mousam Excel Programming 1 July 13th 07 04:28 PM
reset ALL checkboxes (created with control toolbar) with the click of ONE BUTTON [email protected] Excel Programming 1 July 7th 07 07:27 PM
Custom button on toolbar Jack Excel Programming 1 February 7th 06 09:09 PM
Delete a custom button by holding down the ALT key and dragging the button off the toolbar Stephen[_8_] Excel Programming 0 April 4th 04 02:22 PM
Can't delete custom button and toolbar Ron de Bruin Excel Programming 1 March 1st 04 09:46 PM


All times are GMT +1. The time now is 10:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"