christer99
IS-IT--Management
- Dec 3, 2001
- 247
How do I remove any images from a Word document using Visual Basic/.NET?
I have tried this:
Dim sh As Shape
For Each sh In .ActiveDocument.Shapes
sh.Select()
.Selection.Delete()
Next sh
and the image is still there (it's an image in the main part of the document. NOT in the header or anything like that). There might be multiple images, so I ideally I would like something that would deleted all the images.
I have also tried this but it doesn't work either:
Dim piint As Integer
For piint = 1 To 200
wrdTemp.ActiveDocument.InlineShapes(i).Delete()
wrdTemp.ActiveDocument.Shapes("Picture " + CStr(piint) + "").Delete()
Next
I have tried this:
Dim sh As Shape
For Each sh In .ActiveDocument.Shapes
sh.Select()
.Selection.Delete()
Next sh
and the image is still there (it's an image in the main part of the document. NOT in the header or anything like that). There might be multiple images, so I ideally I would like something that would deleted all the images.
I have also tried this but it doesn't work either:
Dim piint As Integer
For piint = 1 To 200
wrdTemp.ActiveDocument.InlineShapes(i).Delete()
wrdTemp.ActiveDocument.Shapes("Picture " + CStr(piint) + "").Delete()
Next