#1   Report Post  
Pete
 
Posts: n/a
Default ActiveWorkBook

Is there a Set ActiveWorkBook command available. I have 3 seperate
workbooks open at one time, I wish to perform actions via VBA on
different aspects of each workbook. How do I activate a specific
workbook.

Thanks

Pete

  #2   Report Post  
CLR
 
Posts: n/a
Default

Workbooks("FileName.xls").Activate

Vaya con Dios,
Chuck, CABGx3



"Pete" wrote in message
oups.com...
Is there a Set ActiveWorkBook command available. I have 3 seperate
workbooks open at one time, I wish to perform actions via VBA on
different aspects of each workbook. How do I activate a specific
workbook.

Thanks

Pete



  #3   Report Post  
Nick Hodge
 
Posts: n/a
Default

Pete

You don't need to activate anything to work on it. Set an object variable to
the workbooks as you open them like the code below

Sub CatchWBs()
Dim wb1 As Workbook, wb2 As Workbook, wb3 As Workbook

Set wb1 = Workbooks.Open("C:\Workbook1.xls")
Set wb2 = Workbooks.Open("C:\Workbook2.xls")
Set wb3 = Workbooks.Open("C:\Workbook3.xls")

'Just some random things to do with each workbook
wb1.PrintOut
wb2.PrintPreview
wb3.Protect

Set wb1 = Nothing
Set wb2 = Nothing
Set wb3 = Nothing

End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS

"Pete" wrote in message
oups.com...
Is there a Set ActiveWorkBook command available. I have 3 seperate
workbooks open at one time, I wish to perform actions via VBA on
different aspects of each workbook. How do I activate a specific
workbook.

Thanks

Pete



  #4   Report Post  
Pete
 
Posts: n/a
Default

thanks, I'll give it a try.

Pete

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"