ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Why do i have to re-assign macro's all the time (https://www.excelbanter.com/excel-programming/301859-why-do-i-have-re-assign-macros-all-time.html)

Simon Lloyd[_492_]

Why do i have to re-assign macro's all the time
 
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

--
Message posted from http://www.ExcelForum.com


Greg Koppel

Why do i have to re-assign macro's all the time
 
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

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

Simon


---
Message posted from http://www.ExcelForum.com/




Simon Lloyd[_494_]

Why do i have to re-assign macro's all the time
 
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

--
Message posted from http://www.ExcelForum.com


Simon Lloyd[_496_]

Why do i have to re-assign macro's all the time
 
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


---
Message posted from http://www.ExcelForum.com/


Simon Lloyd[_500_]

Why do i have to re-assign macro's all the time
 
Can anyone shed a little extra light on the above....call me thick bu
im having a little trouble fathoming it out!

Simo

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 03:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com