I'm trying to write a macro to remove word art

Dspace

New Member
Joined
Nov 2, 2020
Messages
24
Office Version
  1. 365
Platform
  1. Windows
I'm trying to write a macro that displays a "price estimate only" & then the opposite that removes the "price estimate only". The first one is working fine but I can't get the 2nd one to work. I'm sure its a simple mistake but I'm banging my head against the wall. Your help is appreciated. Thanks. there are 2 other logos on the worksheet so I can't select all shapes & delete. Just the word art.

Sub WaterMark()
Dim shp As Shape
Set shp = ActiveSheet.Shapes.AddTextEffect(msoTextEffect, "Price Estimate Only", "Arial", 100, False, False, 0, 0)
With shp
.Fill.Transparency = 1
.Line.Transparency = 1
End With
End Sub

Sub RemoveWaterMark()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If shp.Type = msoTextEffect Then
shp.Delete

End If
Next shp

End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
You would have to use shp.Type = 1, but if you want to identify it, use something like this:

VBA Code:
Sub WaterMark()
Dim shp As Shape
Set shp = ActiveSheet.Shapes.AddTextEffect(msoTextEffect, "Price Estimate Only", "Arial", 100, False, False, 0, 0)
With shp
    .Fill.Transparency = 1
    .Line.Transparency = 1
    .Title = "Price Estimate Only"
End With
End Sub

Sub RemoveWaterMark()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
    If shp.Title = "Price Estimate Only" Then
    shp.Delete

    End If
Next shp
 
Upvote 0
Another variation
VBA Code:
Sub RemoveWaterMark()
    Dim shp As Shape
    
    For Each shp In ActiveSheet.Shapes
        If shp.Type = msoAutoShape Then
            If shp.AutoShapeType = msoShapeRectangle Then
                If shp.TextFrame2.TextRange.Text = "Price Estimate Only" Then
                    shp.Delete
                End If
            End If
        End If
    Next shp
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top