Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-26-2023, 07:54 AM
TheBigBoss TheBigBoss is offline Finding watermarks in document Windows 10 Finding watermarks in document Office 2016
Advanced Beginner
Finding watermarks in document
 
Join Date: Dec 2016
Posts: 56
TheBigBoss is on a distinguished road
Default Finding watermarks in document

Trying to find custom DRAFT watermarks (inserted in Header) and delete them. Should be simple but this macro totally missbehave, it will always return True at "if" statement, yet it counts 0 shapes and doesn't return oSh.Type or oSh.TextEffect.Text?? Is it because oHF is as HeaderFooter and not Header?



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
                    Debug.Print "Shape Text - " & oSh.TextEffect.Text
                    Debug.Print "Shape Type - " & oSh.Type
                    If oSh.Type = 13 Then
                        Debug.Print "Do you reach here? Really!?"
                        If oSh.Name Like "Picture*" And oSh.TextEffect.Text = "DRAFT" Then
                            oSh.Delete
                            i = i + 1
                        End If
                    End If
                Next oSh
            Next oHF
        Next oS
        Debug.Print i
Exit Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding watermarks in document Finding information on a long running document. Balliol Word 8 03-04-2016 09:03 AM
Finding watermarks in document Creating multiple PDF's from word document with different watermarks mlewis Word 1 06-03-2014 08:07 AM
Finding watermarks in document Finding duplicate sentences in a document seascape Word VBA 1 02-18-2014 12:31 AM
Finding watermarks in document Finding or searching ^ character in word document shahin3121 Word 2 03-05-2012 06:16 PM
Finding where I last worked on a document. Balliol Word 1 11-24-2010 04:50 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:13 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft