[VBA] Determine if a variable has no object

  • Thread starter Thread starter Madla
  • Start date Start date
M

Madla

I want to determine if a variable contains a valid shape.

Here's what I'd like to do:

dim aShape as shape

<snip lots of code that may assign a shape to the variable aShape or
not>

if not isNull(aShape) then
'only perform this section if aShape has a reference to a valid shape
end if

<some more code>

I tried isNull, isEmpty, isError but none of these work.

Any ideas? Thanks...martin
 
Try
IsObject(aShape)

--
Bill Dilworth, Microsoft PPT MVP
===============
Please spend a few minutes checking vestprog2@
out www.pptfaq.com This link will yahoo.
answer most of our questions, before com
you think to ask them.

Change org to com to defuse anti-spam,
ant-virus, anti-nuisance misdirection.
..
..
 
You could try ...

If IsObject(aShape) then ....


--
Bill Dilworth, Microsoft PPT MVP
===============
Please spend a few minutes checking vestprog2@
out www.pptfaq.com This link will yahoo.
answer most of our questions, before com
you think to ask them.

Change org to com to defuse anti-spam,
ant-virus, anti-nuisance misdirection.
..
..
 
I want to determine if a variable contains a valid shape.

Here's what I'd like to do:

dim aShape as shape

<snip lots of code that may assign a shape to the variable aShape or
not>

if not isNull(aShape) then
'only perform this section if aShape has a reference to a valid shape
end if

<some more code>

I tried isNull, isEmpty, isError but none of these work.


If aShape is Nothing then
msgbox "Nothing here"
Else
msgbox aShape.Name & "'s the name, PowerPoint's the game"
End if
 
You're right (of course). I had used it on an ugly bit of code (long since
trashed) to assess a variant type. If the variable is dimmed as a shape,
then the content, or lack thereof, does not matter: IsObject always returns
True.

--
Bill Dilworth, Microsoft PPT MVP


Steve Rindsberg said:
Try
IsObject(aShape)

I think that'll tell you what the variable was dimmed as, empty or not.

[clicketa typeta clicketa mousiemousie]

Yup.
 
Back
Top