![]() |
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 |
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 |
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 |
thanks, I'll give it a try.
Pete |
All times are GMT +1. The time now is 11:44 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com