You are here:

Excel/run macro from another workbook


Good day Jan,
I'm struggling about this.
I am currently in a workbook ABC and via a macro, I opened another workbook DEF.  I now want to run an existing macro in the file DEF from being in the file ABC.
Here is what I've done
The two first code don't work and the last one did.
Looks like it doesn't like the "&" or "(" in the filename.

My Question:  I do not want to rename my file.  Is there a work around that will allow me to use the "&" or "(" in the filename ?

Don't work:   Application.Run "ALDO_Risk&Opsv2.xls!UnhideAllSheets"
Don't work:   Application.Run "ALDO_RiskOps(v2).xls!UnhideAllSheets"
Work:   Application.Run "ALDO_RiskOpsv2.xls!UnhideAllSheets"

The trick is to surround the filename with apostrphes:

Application.Run "'ALDO_Risk&opsv2.xls'!UnhideAllSheets"

If that file haapens to be the activeworkbook, you can:

Application.Run "'" ActiveWorkbook.Name & "'!UnhideAllSheets"

Or if the filename is in a variable:

Application.Run "'" sFileName & "'!UnhideAllSheets"
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Jan Karel Pieterse


Excel and Excel/VBA questions


Excel MVP

Self employed Excel developer

Bachelor in Chemical Engineering

Awards and Honors
Microsoft MVP award since 2002

Past/Present Clients
Shell, Fortis bank, ABN-AMRO bank, Morgan Stanley, ...

©2016 All rights reserved.