Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting a workbook...

Status
Not open for further replies.

t16turbo

Programmer
Mar 22, 2005
315
GB
probably such a simple question, but if I have several workbooks open, how can I 'focus' on a particular one for some VBA processing?

like the sheets select function - but with complete workbooks...
 
Have a look at the Activate method of the Workbook object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
hi PH,

Workbook does not seem to have an 'activate' method... :-(
there is an 'Open'
which I have used to open 10 workbooks:
Code:
Workbooks.Open "\\Shylock\ODC Public\FOB\Current Month\hdw.xls"
Workbooks.Open "\\Shylock\ODC Public\FOB\Current Month\hp.xls"
Workbooks.Open "\\Shylock\ODC Public\FOB\Current Month\hwr.xls"
Workbooks.Open "\\Shylock\ODC Public\FOB\Current Month\net.xls"
Workbooks.Open "\\Shylock\ODC Public\FOB\Current Month\serv.xls"
Workbooks.Open "\\Shylock\ODC Public\FOB\Current Month\hfo.xls"
Workbooks.Open "\\Shylock\ODC Public\FOB\Current Month\msg.xls"
Workbooks.Open "\\Shylock\ODC Public\FOB\Current Month\hre.xls"
Workbooks.Open "\\Shylock\ODC Public\FOB\Current Month\central.xls"

ust need to focus on a specified one.
i've tried Workbooks("name").Activate, but that doesn't seem to work!

any ideas?
 
Workbooks("serv.xls").Activate

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
To discover the proper name to use:
For i = 1 To Workbooks.Count
MsgBox "Workbooks(" & i & ")=Workbooks(""" & Workbooks(i).Name & """)"
Next

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
oh.
I wonder why that didn't work when I tried it before... :-(

thanks Glenn and PH :)
 
Of course, you generally don't need to either activate or select the workbook. If you know the workbook's name, you could instead use:
With Workbooks("MyWorkbook.xls")
'do stuff here
End With

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top