N
Nick Hanning
I have many 1000s of documents which I want to open, find and delete
pictures, save, close and move on to the next. The documents are
stored in History files organised into folders so the macro needs to
locate all files within these subfolders.
This is all fine in principle. Via various sources etc. I have created
a macro which checks for Shapes (including first converting any which
are InlineShapes), selects and then deletes these.
I have then inserted this into the publicly available code for finding
all files within a folder (including subfolders) [special thanks to
the MS folks for that!].
Problem is that the Shapes macro works fine on single documents but,
for some reason, when it is operating within the file find loop, it
crashes at the Convert from Inline stage and closes Word altogether. I
assumed maybe it was a resources type issue so have tried limiting the
scope of the search by running on only a few folders at a time (there
are actually 2 main folders each of which has 1000 subfolders) and
then to running on 1 folder at a time (each folder has up to 1000
documents). None of this seems to work.
If the document is open and I run the Shapes bit on its own, it works
fine.
If I run the file search and open macro, then the same command causes
the system to fall over.
Does anyone have any bright ideas at all?
For reference the Shapes part of the code is:
If ActiveDocument.InlineShapes.Count > 0 Then
For Each iShape In ActiveDocument.InlineShapes
iShape.ConvertToShape
Next iShape
End If
If ActiveDocument.Shapes.Count > 0 Then
ActiveDocument.Shapes.SelectAll
Selection.Delete
End If
pictures, save, close and move on to the next. The documents are
stored in History files organised into folders so the macro needs to
locate all files within these subfolders.
This is all fine in principle. Via various sources etc. I have created
a macro which checks for Shapes (including first converting any which
are InlineShapes), selects and then deletes these.
I have then inserted this into the publicly available code for finding
all files within a folder (including subfolders) [special thanks to
the MS folks for that!].
Problem is that the Shapes macro works fine on single documents but,
for some reason, when it is operating within the file find loop, it
crashes at the Convert from Inline stage and closes Word altogether. I
assumed maybe it was a resources type issue so have tried limiting the
scope of the search by running on only a few folders at a time (there
are actually 2 main folders each of which has 1000 subfolders) and
then to running on 1 folder at a time (each folder has up to 1000
documents). None of this seems to work.
If the document is open and I run the Shapes bit on its own, it works
fine.
If I run the file search and open macro, then the same command causes
the system to fall over.
Does anyone have any bright ideas at all?
For reference the Shapes part of the code is:
If ActiveDocument.InlineShapes.Count > 0 Then
For Each iShape In ActiveDocument.InlineShapes
iShape.ConvertToShape
Next iShape
End If
If ActiveDocument.Shapes.Count > 0 Then
ActiveDocument.Shapes.SelectAll
Selection.Delete
End If