Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Referencing an opened Workbook

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
bac bac is offline
external usenet poster
 
Posts: 76
Default Referencing an opened Workbook

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



"BerkshireGuy" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Referencing an opened Workbook


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 :

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



"BerkshireGuy" wrote:

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


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening a workbook if not opened, going to it if already opened neotokyo[_3_] Excel Programming 0 September 24th 04 08:56 PM
Opening a workbook if not opened, going to it if already opened neotokyo[_2_] Excel Programming 1 September 24th 04 07:17 PM
Opening a workbook if not opened, going to it if already opened neotokyo Excel Programming 1 September 24th 04 06:33 PM
How to see if the opened workbook is opened by another user ? balexis Excel Programming 1 August 18th 04 04:11 PM
Sheets select method fails when workbook is opened by another workbook Mike Excel Programming 2 June 8th 04 04:17 AM


All times are GMT +1. The time now is 10:13 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"