Multi-word WB name

  • Thread starter Thread starter Otto Moehrbach
  • Start date Start date
O

Otto Moehrbach

Excel XP & Win XP
I have 2 workbooks open, AAA.xls & BBB.xls.
I want to run macro TestBBB, located in BBB.xls, from within AAA.xls.
The code (in AAA.xls):
Application.Run ("BBB.xls!TestBBB")
works fine (thanks to Mark Dullingham).

Now change the scenario:
Change the name of the BBB.xls WB to "BB B.xls" (insert a space in the name)
The code (in AAA.xls):
Application.Run ("BB B.xls!TestBBB")
produces an error "Macro 'BB B.xls!TestBBB' cannot be found."

My question: What is the proper syntax for the Application.Run statement
when the target workbook has a multi-word name?
Thanks for your time. Otto
 
Application.Run ("'BB B.xls'!TestBBB")


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
You need single quotes around the filename.

ie
Application.Run ("'BB B.xls'!TestBBB")
 
Hi, Otto,

Enclose the workbook name in single quotes.

Application.Run("'BB B.xls'!TestBBB")
 
How about:
Application.Run "'BB B.xls'!TestBBB"
(not ()'s required)

I like:

dim BBBWkbk as workbook
set BBBwkbk = workbooks("bb b.xls") 'or whatever
Application.Run "'" & BBBwkbk.name & "'!TestBBB"

By using a variable, I only have one location to change if/when that workbook
needs to change.
 

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

Back
Top