View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default run time error 9

Something like this

Dim oWB1 As Workbook
Dim oWB2 As Workbook

Set oWB1 = Workbooks.Open("C:\MyTest\File1.xls")

'do some stuff

Set oWB2 = Workbooks.Open("C:\OtherDir\Subdir\File2.xls")

'now you have references to the 2 workbooks
'no need to activate, switch, or such nonsense

'now use them

Call DoSomething(oWB1)

Call DoSomething(oWB2)

...

Sub DoSomething(oWB As Workbook)
MsgBox oWB.Name
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"SandyUK" wrote in
message ...

Hi Bob

I think I understand the theory of what you are suggesting and I have
searched the site for workbook object variables but with no joy. Any
chance you could dumb it down for me or provide a little more detail?

Adrian


--
SandyUK
------------------------------------------------------------------------
SandyUK's Profile:

http://www.excelforum.com/member.php...o&userid=17487
View this thread: http://www.excelforum.com/showthread...hreadid=547362