Referencing an opened Workbook

  • Thread starter Thread starter BerkshireGuy
  • Start date Start date
B

BerkshireGuy

Hello all,

In an Access 2000 module, I have a routine that creates a new excel
workbook (so its called Book1) and copies rows from Access to the Excel
workbook.

Then in a subroutine, I want to do some other stuff with the OPENED
workbook.

What would be the proper way of referencing an OPENED Excel workbook?

Thanks,
Brian
 
When you open the new workbook you should save the workbook's name into a
variable:

new_woorkbook = activeworkbook.name

then you can always get to that workbook with:

workbooks(new_workbook).activate

please rate this post below

thanx
bac
 
better to use a workbook object variable.

use a module level variable:

dim mWkb as Excel.Workbook

sub ProcA()
set mWkb=workbooks.open("c:\book.xls")
end sub

sub ProcB()
if not mWkb is nothing
then mWkb.close
end if
end sub

OR (better?) use arguments..

sub ProcC()
dim wkb as Excel.Workbook
set wkb=workbooks.open("c:\book.xls")
call ProcD(wkb)
end sub

sub ProcD(wkb as Excel.Workbook)
if not wkb is nothing
then wkb.close
end if
end sub



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


BAC wrote :
 
Back
Top