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
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" <[email protected]> wrote in message
news:[email protected]...
> 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
[email protected]HIS
"Pete" <[email protected]> wrote in message
news:[email protected]...
> 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
Pete uve been giving it a try since 2005? U ungrateful *******
Although we encourage members to marked threads as SOLVED, it is not required and not done automatically. Just because time has passed doesn't mean it is solved.
And to eeijas, there is no need to post to an old thread to offer nothing of value and only an insult. Do not do this again. Any further activity in this thread that is not related to the topic will result in a locked thread.
I can see that this thread should have been closed some time back, but adding posts that serve NO value on a thread is both unnecessary and unwarranted. Further posts of this nature will be dealt with accordingly
Thanks
1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
2. If your question is resolved, mark it SOLVED using the thread tools
3. Click on the star if you think someone helped you
Regards
Ford
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks