![]() |
#1
|
|||
|
|||
![]() In case Word is not able to retrieve an image when you paste an article from the web (because of a bad connection, for example), it will instead insert a placeholder on that location. I am trying to remove these, and so far I have the code below, but it's far from working as it should... Code:
For Each oShape In ActiveDocument.Shapes If oShape.AutoShapeType = msoShapeRectangle Then oShape.Delete End If Next Then, how can I execute the code for the current selection only, instead of the entire document? Thank you! Alex |
#2
|
||||
|
||||
![]()
On your first question, loops that delete items should always start from the back of the line rather than starting from the front. Imagine you have a queue of items where you remove item 3 and step to (the now) item 4. The end effect of this is that your loop skips any item immediately after any item that is deleted.
To avoid this procedural issue, you start from the back Code:
For i = ActiveDocument.Shapes.Count to 1 Step -1 If ActiveDocument.Shapes(i).AutoShapeType = msoShapeRectangle then ActiveDocument.Shapes(i).Delete Next i If you have selected the shapes themselves, you can use Selection.ShapeRange.Count If you have selected the text where some shapes are anchored, this is much more difficult and you would need to loop through all the ActiveDocument.Shapes and test whether their anchor is in the selected text.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
![]()
Indeed, looping from the back made all the difference! The code does now replace all the image placeholders.
Thank you! Alex |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Placeholders | Marina | Word | 9 | 12-17-2019 03:28 PM |
How do I animate so: small image ==> large image ==> text over overlaid ==> back to next image | ship69 | PowerPoint | 0 | 09-27-2019 12:55 PM |
Remove image paths from Word to PDF convertion | gwk1975 | Word | 0 | 07-30-2014 05:02 AM |
Description of Uses/Differences in Placeholders | CathClaud | Mail Merge | 6 | 06-23-2014 06:31 PM |
![]() |
DeadBatteries | Word | 3 | 08-23-2012 01:08 AM |