ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check an object reference (https://www.excelbanter.com/excel-programming/399678-check-object-reference.html)

XP

Check an object reference
 
Using Office 2003 and Windows XP;

I have an object reference to a file, call it "goFile".

I need to be able to do two things with this reference:

1. Determine if the file it is refering to is open.

2. Determine if the reference is set to anything.

Could someone please post example code that illustrates these two things?

Thanks much in advance.

joel

Check an object reference
 
if gofile is not nothing then
For Each wbk In Workbooks
if wbk.name = gofile then
' Enter code here
end if
next wbk
end if

"XP" wrote:

Using Office 2003 and Windows XP;

I have an object reference to a file, call it "goFile".

I need to be able to do two things with this reference:

1. Determine if the file it is refering to is open.

2. Determine if the reference is set to anything.

Could someone please post example code that illustrates these two things?

Thanks much in advance.


JP[_3_]

Check an object reference
 
Hello,

Sorry to butt in but I think the actual syntax should be:

If Not gofile Is Nothing


HTH,
JP


On Oct 19, 5:50 pm, Joel wrote:
if gofile is not nothing then
For Each wbk In Workbooks
if wbk.name = gofile then
' Enter code here
end if
next wbk
end if



"XP" wrote:
Using Office 2003 and Windows XP;


I have an object reference to a file, call it "goFile".


I need to be able to do two things with this reference:


1. Determine if the file it is refering to is open.


2. Determine if the reference is set to anything.


Could someone please post example code that illustrates these two things?


Thanks much in advance.- Hide quoted text -


- Show quoted text -





All times are GMT +1. The time now is 05:28 PM.

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