Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default excel isObject or collection exists

how is the syntex in vba excel to check: if object exists, or is
object in collection exists.

I tried this code in vba excel :

if (oElement.Attributes("backGroundColor")) then
.... do something

but got error.

in VBA code there are some common object instance,checking
like: isObject(obj)=0
or: obj=null
or: obj is nothing
or empty
none of above works ??
only something like on error resume next ?? (not very common)
why excel VBA is different from other VBA like MS-Access ?

el

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default excel isObject or collection exists

Hi
There are probably neater ways of doing it but I tend to use

err.clear
On error Resume next
Set ObjectName = myobject
On Error goto 0
If err.number = 0 then
'myobject exists and I can use it
End if

err exists while excel is open so must be cleared first.

regards
Paul

On Jan 24, 8:20*am, ell wrote:
how is the syntex in vba excel to check: if object exists, or is
object in collection exists.

I tried this code in vba excel :

if (oElement.Attributes("backGroundColor")) then
... do something

but got error.

in VBA code there are some common object instance,checking
like: isObject(obj)=0
or: obj=null
or: *obj is nothing
or empty
none of above works ??
only something like on error resume next ?? (not very common)
why excel VBA is different from other VBA like MS-Access ?

el


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
How can I check a collection (e.g. worksheets) collection to be empty? Michiel via OfficeKB.com Excel Programming 2 March 25th 10 02:22 PM
Collection Look Up - By Key in an Excel VBA App. vmegha Excel Programming 3 January 19th 06 03:00 PM
excel columns collection? Ron Excel Programming 3 April 5th 05 09:20 PM
How to check if a worksheet exists in worksheet collection Raghunandan Excel Programming 2 July 19th 04 06:55 AM


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