can anyone see what's wrong with this

it spose to iterate through all picture objects & cut n paste them back

it errors on the very first picture (item(1)) it finds

With ActiveDocument
If .Shapes.Count > 0 Then
With .Shapes
For x = 1 To .Count
.Item(x).Select
Selection.Cut
Selection.PasteAndFormat (wdPasteDefault) <<<<<<<<<<<
error here (on item 1)
Next
End With
End If
If .InlineShapes.Count > 0 Then
With .InlineShapes
For x = 1 To .Count
.Item(x).Select
Selection.Cut
Selection.PasteAndFormat (wdPasteDefault)
Next
End With
End If
End With

RE: can anyone see what's wrong with this ? by MellaBel

MellaBel
Fri Oct 22 04:43:04 CDT 2004

Hi there,

you should check that ActiveDocument is not equal to Nothing!
Also check if your count is greater than1, otherwise, if count == 0, the
For-Loop will crash. I suppose that's why it crashes.

Regards
Mel

"JethroUK©" wrote:

> can anyone see what's wrong with this
>
> it spose to iterate through all picture objects & cut n paste them back
>
> it errors on the very first picture (item(1)) it finds
>
> With ActiveDocument
> If .Shapes.Count > 0 Then
> With .Shapes
> For x = 1 To .Count
> .Item(x).Select
> Selection.Cut
> Selection.PasteAndFormat (wdPasteDefault) <<<<<<<<<<<
> error here (on item 1)
> Next
> End With
> End If
> If .InlineShapes.Count > 0 Then
> With .InlineShapes
> For x = 1 To .Count
> .Item(x).Select
> Selection.Cut
> Selection.PasteAndFormat (wdPasteDefault)
> Next
> End With
> End If
> End With
>
>
>