VBA to watermark all sheets

winrz

Board Regular
Joined
Sep 4, 2002
Messages
106
I have harvested some code in order to create a watermark on all sheets within a workbook. The problem is - the watermarks are placed on only the first (active) sheet (one on top of another). How do i get the VBA to move over the next sheet, and the next, and so on. Staring at the code but its not coming to me. Anyone see my problem(s)?

Sub AddWatermark()

' Inserts a wordart "watermark" onto the current sheet with its
' upper left corner positioned on the upper left corner of the
' selected cell.

Dim StrIn As String
StrIn = InputBox("Enter watermark text")
If StrIn = "" Then Exit Sub

Dim ws As Worksheet
For Each ws In Worksheets

With ActiveSheet.Shapes.AddTextEffect(msoTextEffect3, StrIn, _
"Arial Black", 72#, msoFalse, msoFalse, _
10, 10)
.ScaleWidth 1, msoFalse, msoScaleFromTopLeft
.ScaleHeight 1, msoFalse, msoScaleFromBottomRight
.Fill.Visible = msoFalse
.Fill.Solid
'.Fill.ForeColor.SchemeColor = 26
.Fill.Transparency = 0.3
.Shadow.Transparency = 0.4
.Line.Visible = msoFalse
'position at cell corner
'.Top = Selection.Top
.Top = 25
.Left = 25
'.Left = Selection.Left
End With

Next ws

End Sub
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Try this instead:

Code:
Sub AddWatermark()

' Inserts a wordart "watermark" onto the current sheet with its
' upper left corner positioned on the upper left corner of the
' selected cell.

Dim StrIn As String
StrIn = InputBox("Enter watermark text")
If StrIn = "" Then Exit Sub

Dim ws As Worksheet
For Each ws In Worksheets

With [B][U]WS[/U][/B].Shapes.AddTextEffect(msoTextEffect3, StrIn, _
"Arial Black", 72#, msoFalse, msoFalse, _
10, 10)
.ScaleWidth 1, msoFalse, msoScaleFromTopLeft
.ScaleHeight 1, msoFalse, msoScaleFromBottomRight
.Fill.Visible = msoFalse
.Fill.Solid
'.Fill.ForeColor.SchemeColor = 26
.Fill.Transparency = 0.3
.Shadow.Transparency = 0.4
.Line.Visible = msoFalse
'position at cell corner
'.Top = Selection.Top
.Top = 25
.Left = 25
'.Left = Selection.Left
End With

Next ws

End Sub

HTH

Hank
 
Upvote 0
Hank, thanks. Funny, I did try that before without luck - must have had another variable out of whack.
Thanks.
 
Upvote 0

Forum statistics

Threads
1,217,132
Messages
6,134,827
Members
449,890
Latest member
xpat

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