Link to home
Start Free TrialLog in
Avatar of Iver Erling Arva
Iver Erling ArvaFlag for Norway

asked on

Calling a macro in another open Excel workbook, Excel automatically adds path and hence cannot find macro.

Hi!

This happens in Excel 2013:

1. I open a macro enabled workbook A
2. In that workbook A, I open workbook B using a macro calling a template B0.
3. Both workbooks A and B0 are stored in the same directory C:\Excelstuff\myDir
4. In Workbook B, there is a button connected to a macro.
5. The macro is stored in Workbook A.
6. In the properties of the button in workbook B0 (tablet), the reference entered is to WorkbookA!This workbook.Macro1
7.When I try to click the button in the newly opened workbook A, it tells me that the macro cannot be found. The reason is that the path C:\Excelstuff\myDir is automatically added in front of WorkbookA!ThisWorkbook.Macro1

Can anyone please help!

Thanks!
Avatar of [ fanpages ]
[ fanpages ]

That behaviour sounds like it should be happening; i.e. fully-qualified filenames to ensure the correct routine is being executed.

In your question you seem to swap between referring to "B0" as a 'template', a 'tablet', & a 'workbook', so am I not entirely sure what it being called within "B0", but can you move "Macro1" in "WorkbookA" from 'ThisWorkbook' to a Public code module to establish if the reason for it not being found is because it is Private to "WorkbookA"?
Hi,

pls verify the spelling of your "assign to" macro

Regards
ASKER CERTIFIED SOLUTION
Avatar of Iver Erling Arva
Iver Erling Arva
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Iver Erling Arva

ASKER

Now it works as expected.