Delete an inlineshape object

P

per

Hi there.
I have a Word template with many image controls in it. The
user is supposed to drag-and-drop pictures into these
images. Once in a while end-user marks the hole image
control, and hit the delete button.
In one of my VBA-Macros I try to delete alle inlineshapes
in the document, and when I try to delete the one which
already has been deleted by the end-user, Word dies. How
can I found out that this inlineshape object is already
deleted, before I try to do this in VBA.

per
 
H

Helmut Weber

Hi,
show us your code.
If you use something like
for i = 1 to inlineshapes.count
delete inlineshape(i)
next
you will always run into trouble.
 
G

Guest

Hi Helmet, here is my VBA code:
For lLoop = ActiveDocument.InlineShapes.Count To 1 Step (-
1)
If Not ActiveDocument.InlineShapes(lLoop) Is Nothing Then

If IsObjectValid(ActiveDocument.InlineShapes(lLoop)) =
True Then
ActiveDocument.InlineShapes(lLoop).Delete
End If

End If
Next
 
H

Helmut Weber

Hi,
your code seems overcomplicated to me,
but works perfectly here and now.
A simple solution would be:
 

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