View Single Post
 
Old 10-27-2023, 02:26 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Try this instead - watermarks inserted by Word's Watermark function won't get found with your code. Your oSh.Type = 13 wouldn't return a standard watermark on my machine. Nor would it match on oSh.Name.
Code:
Sub FixHeaderFooter()
  Dim oD As Document, oS As Section, oHF As HeaderFooter, oSh As Shape, tmp As String, r As Range, i As Integer
  Set oD = ActiveDocument
  Debug.Print "FIX HEADER/FOOTER--------------------------------"
  For Each oS In oD.Sections
      Debug.Print "Section"
      For Each oHF In oS.Headers
          Debug.Print "Header/footer - " & oHF.Shapes.Count & " shape(s)"
          For Each oSh In oHF.Shapes
              Debug.Print "Shape Text - " & oSh.TextEffect.Text
              Debug.Print "Shape Type - " & oSh.Type
              If oSh.Type = msoTextEffect Then      'msoTextEffect = 15
                  Debug.Print "Do you reach here? Really!?"
                  If oSh.TextEffect.Text = "DRAFT" Then
                      oSh.Delete
                      i = i + 1
                  End If
              End If
          Next oSh
      Next oHF
  Next oS
  Debug.Print i
End Sub
If that doesn't work, perhaps you need to post a sample document that shows what your watermarks actually contain.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote