Can you provide a sample of your macro?
Jerid
Here is a sample simple macro I have. I just noticed also, that if I move the original file to any location other than originally saved, my customized macro buttons no longer work. It is somehow always appending the path and file name to the macro attatched to each button.
THanks for any help
Sub VTS()
'
' VTS Macro
' Macro recorded 8/22/2001 by GE Medical Systems
'
Sheets("VTR Documentation").Visible = False
Sheets("VTS Title Sheet").Select
Range("A1").Select
'
End Sub
for any help VTS Macro Macro recorded 8/22/2001 by GE Medical Systems
It's because when you assign the button to your Macro, Excel automaticly add the workbook name.
You are better off with a procedure that builds the toolbar for you. This is an example of what I do.
From Excel press Alt F11 to open the VBE, select insert module and copy this code into it. Make changes as needed.
[EXAMPLE - Must be in a Module]
Public TBarMenuBar As CommandBar
'Runs when the workbook is opened
Sub Auto_Open()
Dim TBarMenu As Object
'~~~~ Creates CommandBar ~~~~
Set TBarMenuBar = Application.CommandBars.Add(Name:="MyCmdBar", Position:=msoBarTop, Temporary:=True)
'#### Creates custom menu items ####
With TBarMenuBar.Controls
'~~~~ Create Button for MyMacro ~~~~
Set TBarMenu = .Add(Type:=msoControlButton, Temporary:=True)
TBarMenu.Caption = "My Macro"
TBarMenu.FaceId = 284
TBarMenu.OnAction = "MyMacro"
TBarMenu.Visible = True
End With
'~~~~ Make new bar visible ~~~~
TBarMenuBar.Visible = True
End Sub
'Your Macro
Sub MyMacro()
MsgBox "Test Macro"
End Sub
'Runs when the workbook is closed
Sub Auto_Close()
Application.CommandBars("MyCmdBar").Delete
End Sub
Hope this helps, Jerid
Thank you so much...that is exactly what I needed! Take care.
CHris
VTS Macro Macro recorded 8/22/2001 by GE Medical Systems '#### Creates custom menu items #### With TBarMenuBar.Controls '~~~~ Create Button for MyMacro ~~~~ Set TBarMenu = .Add(Type:=msoControlButton, Temporary:=True) TBarMenu.Caption = "My Macro" TBarMenu.FaceId = 284 TBarMenu.OnAction = "MyMacro" TBarMenu.Visible = True End With '~~~~ Make new bar visible ~~~~ TBarMenuBar.Visible = True 'Your Macro