[VBA] Determine if a variable has no object

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
 
B

Bill Dilworth

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.
..
..
 
B

Bill Dilworth

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.
..
..
 
S

Steve Rindsberg

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
 
B

Bill Dilworth

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top