View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default How to check workbook is already opened before passing the workbook obj to a subroutine in Word

Bon,
Presumably if you have a reference to a workbook (your workbook object), you
must have opened it in order to obtain the reference. You can't have a
reference to a file that is not open.
Otherwise you would only have a file name/path.

Why not pass a variant and check if its an object (Excel.Workbook) or a
string and act accordingly

NickHK

"Bon" wrote in message
ups.com...
Hello all

I want to pass a workbook object or a filepath string from a module in
MS Access 2000 to a subroutine in MS Word 2000. Before passing the
object or filepath, I want to check the workbook is already opened or
not. How can I do that?

IF the workbook is already opened
MS Word subroutine will extract excel data from the opened workbook
ELSE
Open the excel workbook
MS Word subroutine extract excel data
End IF

If the workbook has been opened, the workbook is opened in the MS Word
subroutine would be better? Or the workbook is opened in MS Access
would be better?

My whole workflow
Firstly, MS Access calls a module with Workbook obj/filepath as
parameter in MS Word
Secondly, MS Word will extract data from MS Excel and then paste it
under a bookmark in MS Word.

Could anyone give me some advices? Thank you

Cheers
Bon