Custom Toolbar and Assigned Macro

J

Jack Gillis

I have created a custom toolbar that I made visible only when a
particular workbook and a certain sheet is active. There are three
buttons on it each with an attached macro and they do what is expected
as long as the workbook remains in the folder in which it was created
(D:/Devel.) However, if I move that workbook to another folder (My
Documents) and open it by double clicking, the toolbar buttons insists
they can't find the macro because the workbook is no longer in 'Devel'.

I know I can create a workbook which only has the macros, put it in
XLSTART, assign the macros to the buttons and have the buttons find the
macros no matter where the workbook resides. (At least, I think I can.)

Is there a way I can keep the macros with the workbook and have the
buttons find them no matter where the workbook lives?

Thank you.
 
J

Jack Gillis

A follow up:

I have put them in Personal.xls and things work as expected But I
really don't want them visible to all workbooks so that is why I want to
keep them with the parent workbook, if that makes sense.

Thanks again.
 
B

Bob Phillips

In the target workbook workbook_Open event, reset the Onaction property of
the toolbar.

Private Sub Workbook_Open()
With Application.CommandBars("myBar")
.Visible = True
With .Controls("Control1")
.OnAction = "myMacro"
End With
End With
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
J

Jack Gillis

Thank you. I knew there must be a way.


Bob Phillips said:
In the target workbook workbook_Open event, reset the Onaction
property of
the toolbar.

Private Sub Workbook_Open()
With Application.CommandBars("myBar")
.Visible = True
With .Controls("Control1")
.OnAction = "myMacro"
End With
End With
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top