Good day!
Looking at using VBA to remove a photo/jpg from a word doc using button presses via user form. Example: If I wanted to create a memo, then it keeps it. If I wanted to create another form (not memo) then removes photo. I have the photo pre-positioned using warp text formatted to the right. I've tried using the Find/Search function in word to find special graphic to replace it. >g but it could not find the jpg that I wanted to remove. It seems that Word doesnt detect that photo/jpg. see picture.
My code that I tried;
Private Sub CommandButton4_Click()
ActiveDocument.Bookmarks("memodep").Delete
ActiveDocument.Bookmarks("memounit").Delete
ActiveDocument.Bookmarks("memoloc").Delete
ActiveDocument.Bookmarks("memoaddress").Delete
Do While ActiveDocument.InlineShapes.Count > 0
ActiveDocument.InlineShapes(1).Delete
Loop
Intro.Hide
OPORD.Show
or
Dim dod.jpg As InlineShape
For Each objPic In ActiveDocument.InlineShapes
objPic.Delete
Next objPic
End Sub
Intro.Hide
OPORD.Show
"I have the photo pre-positioned using warp text formatted to the right."
This means that the logo is a Shape
rather than an InlineShape
.
Assuming that you only have the one, ActiveDocument.Shapes(1).Delete
should do the job.
Of course, when you delete the logo all of the text to the right of it will move back to the left margin.
EDIT: Your question left out the vital information that the logo is in the header.
Your first task is to determine which section the header is contained in. Your second is to determine which of the 3 possible headers the logo is contained in.
To point you in the right direction:
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Shapes(1).Delete
BTW, dod.jpg is not a valid name for a variable in VBA