PDA

View Full Version : Referencing a Workbook



Aussiebear
05-14-2007, 12:22 PM
I see references to a workbook within code which will use the wb then the workbook name. Almost always the workbook name is a single word. What happens if the Workbook name is multi worded?

Could it be wbBlessMeMother or wbBless Me Mother if the workbook is called Bless Me Mother for example?

Bob Phillips
05-14-2007, 12:36 PM
Enclose in quotes.

mdmackillop
05-14-2007, 02:36 PM
I think you're refering to a variable, so probably
Dim wbBlessMeMother as Workbook
Set wbBlessMeMother = Workbooks("Bless Me Mother.xls")

Aussiebear
05-15-2007, 02:18 AM
So i should concatenate the name when using the workbook name as a reference when declaring it as a dim and Set, but keep its "openness" when using it as Workbooks ("Bless Me Mother")

Bob Phillips
05-15-2007, 02:38 AM
Can you say that in English?

Aussiebear
05-15-2007, 03:56 AM
Don't you mean in Australian.

If I use the Set command then the workbook name needs to be BlessMeMother

If I want to dim the workbook I need to use wbBlessMeMother

However if I refer to the workbook by its name when using Workbooks ("Bless Me Mother"), I need to include the spaces.

If you're coming to Australia Bob, you better brush up on your english:devil2:

Bob Phillips
05-15-2007, 03:58 AM
Assuming that the variable is named BlessMeMother, and the book is named Bless Me Mother, then yes, yes, yes.