Toolbar - Specific connections to a macro

WHYME

New Member
Joined
Jan 12, 2005
Messages
10
At the moment I have created an excel/macro worksheet that works, it calls the information from a database and creates a report file with the specific desired data in it.

The problem is that this file is going to be used and renamed allot of times. At the moment if I run say "Alarms1", the macro connection within the toolbar reads 'D:\Report Template\Test 1\Alarms1.xls'!RunQueries'. This works.

However if I run a file called "Comms1", the macro connection within the toolbar remains 'D:\Report Template\Test 1\Alarms1.xls'!RunQueries'. I must reconnect each time I want to run another file.

I have asked this before and was given (Below). But it doesn't seem to work.

Private Sub Workbook_Open()
Sheets("Sheet 1").Shapes("Button 1").OnAction = ThisWorkbook.Name & "!MyMacro
End Sub

Can anyone suggest the code or even a solution around this?
:oops:
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,148,216
Messages
5,745,431
Members
423,951
Latest member
peggrif

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top