View Single Post
 
Old 05-11-2020, 01:40 AM
alex100 alex100 is offline Windows 7 64bit Office 2016
Advanced Beginner
 
Join Date: May 2020
Posts: 79
alex100 is on a distinguished road
Default

Yes, I just did that, only with a slight modification to your idea.

The 'Find = ^g^p' pattern did not seem to find and replace all the images in the document. Although I am not 100% sure, I believe it failed to replace those images that were not followed by a new line/paragraph. Anyhow, I'm positive it was something related to how the image and the text that followed it were formatted in the source HTML page.

The code below seems to work better, as I tested it quite well.

Code:
Dim oILShp As InlineShape
For Each oILShp In ActiveDocument.InlineShapes
ActiveDocument.Range(oILShp.Range.Start, oILShp.Range.End).Text = "[IMAGE REMOVED]"
Next

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
    .Text = "[IMAGE REMOVED]^p"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Thank you!

Alex
Reply With Quote