Skip to content

Instantly share code, notes, and snippets.

@shinyzhu
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shinyzhu/ad08e3ffe440369d5599 to your computer and use it in GitHub Desktop.
Save shinyzhu/ad08e3ffe440369d5599 to your computer and use it in GitHub Desktop.
Remove some watermarks in Powerpoint template files
Option Explicit
Sub RemoveWatermarks()
'image watermark values
Dim imgWidth As Double, imgHeight As Double, delta As Double
imgWidth = 100.12
imgHeight = 100.12
delta = 0.1
'text watermark values
Dim searchTerm As String
searchTerm = "some watermark text"
Dim txtRange As TextRange, foundRange As TextRange
'slide and shape values
Dim sld As Slide, shp As Shape
'go through each slides
For Each sld In Application.ActivePresentation.Slides
For Each shp In sld.Shapes
'find image watermarks
If shp.Type = msoPicture Then
If Math.Abs(shp.Width - imgWidth) < delta And Math.Abs(shp.Height - imgHeight) < delta Then
'remove the image watermark
shp.Delete
End If
ElseIf shp.HasTextFrame Then
'find text watermarks
Set txtRange = shp.TextFrame.TextRange
Set foundRange = txtRange.Find(FindWhat:=searchTerm, MatchCase:=False, WholeWords:=False)
If (Not foundRange Is Nothing) Then
'remove the text watermarks!
shp.Delete
End If
End If
Next
Next
MsgBox ("all done.")
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment