Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Toolbar Buttons (macros) fail after filename change

I require a toolbar of buttons which are assigned to workbook macros to work when the filename changes. What do I have to do to ensure this? Currently they work until I change the filename then they look to the wrong place...

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Toolbar Buttons (macros) fail after filename change

My preferred option is to recreate the entire toolbar programmatically
each time the workbook is opened. This requires a lot more code however.
The following is the simplest method of solving your problem that I am
aware of. It assumes that none of the controls are msoControlPopup type
- i.e. menu type that have controls of their own. Assumed is that the
toolbar is named "Custom 1" with minimal testing:

Private Sub Workbook_Open()
Dim CB As CommandBar
Dim Ctl As CommandBarControl
Dim Pos As Integer
Dim txt As String

Set CB = Application.CommandBars("Custom 1")
On Error Resume Next
For Each Ctl In CB.Controls
If Ctl.BuiltIn = False Then
txt = Ctl.OnAction
Pos = InStrRev(txt, "!")
txt = Right(txt, Len(txt) - Pos)
Ctl.OnAction = txt
End If
Next
On Error GoTo 0
End Sub



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
Assigning Macros to Toolbar buttons JMay Excel Discussion (Misc queries) 1 July 24th 07 07:22 PM
How can you replicate macros for buttons on the Standard toolbar? Suzi Excel Discussion (Misc queries) 1 February 16th 07 09:53 PM
Names of macros for toolbar buttons DredanZyl[_3_] Excel Programming 3 June 6th 04 10:17 AM
Icons on toolbar buttons (Was: Toolbars with macros) Phil Bewig Excel Programming 1 February 2nd 04 03:49 PM
Problem with macros assigned to toolbar buttons Greg Wilson[_3_] Excel Programming 1 September 8th 03 07:50 PM


All times are GMT +1. The time now is 06:50 AM.

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

About Us

"It's about Microsoft Excel"