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

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,214,981
Messages
6,122,565
Members
449,089
Latest member
Motoracer88

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
Back
Top