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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
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,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

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