Why do i have to re-assign macro's all the time

S

Simon Lloyd

I have four work books which all have pretty much the same code apar
from a few minor changes, and they all use some custom menu bars (th
same for each workbook)......my problem is this...when i re-open th
workbook on another networked machine i have to re-assign macros or i
i open one workbook close it and open another i have to re-assign...wh
is this? is there a solution?

Simo
 
G

Greg Koppel

You need to assign/unassign the macros to the buttons when the workbook is
opened.
Here is the example solution for a toolbar, menus are similar.

Sub Auto_open()
Toolbars("LogForm").Visible = True
Toolbars("LogForm").ToolbarButtons(1).OnAction = "PhoneLogger"
Toolbars("LogForm").ToolbarButtons(2).OnAction = "LateLogger"
End Sub
Sub Auto_close()
On Error Resume Next
Toolbars("LogForm").ToolbarButtons(1).OnAction = ""
Toolbars("LogForm").ToolbarButtons(2).OnAction = ""
Toolbars("LogForm").Visible = False

Toolbars("LogForm").Delete
On Error GoTo 0
End Sub

HTH, Greg
 
S

Simon Lloyd

Hi Greg, thanks fro the reply, i created a menubar which has fou
buutons on it, for arguement sake lets say they are called today
tomorrow, yesterday and daybefore lets say the menuar is calle
everyday......should i replace your titles i.e "PHONELOGGER" with m
button name? i.e "TODAY"

I already turn the menubar on and off in auto_open/close
with
With Application
.CommandBars("Whateverday").Visible = True, but on opening a differen
workbook that also uses this bar i have to re-asign macros, then whe
opening the original again i have to re-assign again.

How do i actually assign the named macros to the named buttons on th
command bars in VBA in the auto_open?


Sorry for seeming a bit dense but ive only been at VB/VBa for about
weeks.

Simo
 
S

Simon Lloyd

In addition to the above how do i determine which is button
1,2,3,4?....i created a new menubar dragged it to the top of the screen
and then dragged some custom buttons on to it and did all the usual
re-naming and stuff!

Simon
 
S

Simon Lloyd

Can anyone shed a little extra light on the above....call me thick bu
im having a little trouble fathoming it out!

Simo
 
Top