ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Testing if a workbook is open (https://www.excelbanter.com/excel-programming/383072-testing-if-workbook-open.html)

Conan Kelly

Testing if a workbook is open
 
Hello all,

How do I test if a workbook is open.

I have some code set up where I copy some data from a source file into a
destination file. This code needs to be run 14 times per source file. I
have the code set to close the source file after the 14th copy process. At
the end of each copy process, I have the code switch to the source file.
Well, if the source file is closed after the 14th copy process, then there
is no source file for the code to switch back to when it is done, and I get
an error.

Thanks for any help anyone can provide,

Conan Kelly



Bob Phillips

Testing if a workbook is open
 

On error Resume Next
Set oWB = Workbooks("myBook.xls")
On Error Goto 0
If oWB Is Nothing Then
Msgbox "workbooks is not open
...


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Conan Kelly" wrote in message
...
Hello all,

How do I test if a workbook is open.

I have some code set up where I copy some data from a source file into a
destination file. This code needs to be run 14 times per source file. I
have the code set to close the source file after the 14th copy process.
At the end of each copy process, I have the code switch to the source
file. Well, if the source file is closed after the 14th copy process, then
there is no source file for the code to switch back to when it is done,
and I get an error.

Thanks for any help anyone can provide,

Conan Kelly





All times are GMT +1. The time now is 07:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com