ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can I toggle this Code - to Stamp and to UnStamp? (https://www.excelbanter.com/excel-programming/287329-can-i-toggle-code-stamp-unstamp.html)

JMay

Can I toggle this Code - to Stamp and to UnStamp?
 
Below code is working just fine; I 've assigned it to a icon on my
Formatting Toolbar.
At present it is a one-directional Stamping of the Text "DRAFT....
I'de like to be able to click on my button "a second time" and have the text
"DRAFT..." disappear; then click again, and have it appear,
((Toggle-type)) - Can this be done?
If how, how would I modify (the code) it?
TIA,

Sub DraftStamp()
With ActiveSheet.Shapes.AddTextEffect( _
msoTextEffect1, "D R A F T" & Chr(10) & "ISSUED " & Date,
"Arial Black", _
24#, msoFalse, msoFalse, Left:=300, Top:=5)
With .Fill
.Visible = msoTrue
.Solid
.ForeColor.SchemeColor = 10
.Transparency = 0.2
End With
With .Line
.Weight = 0.75
.DashStyle = msoLineSolid
.Style = msoLineSingle
.Transparency = 0#
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 0)
.BackColor.RGB = RGB(255, 255, 255)
End With
.LockAspectRatio = msoTrue
.Height = 60#
.Width = 175#
.Rotation = 0#
End With
ActiveSheet.Protect _
DrawingObjects:=True, _
Contents:=False, _
Scenarios:=False
End Sub



Tom Ogilvy

Can I toggle this Code - to Stamp and to UnStamp?
 
Assuming you don't have other wordart on the sheet:

Sub DraftStamp()
For Each shp In ActiveSheet.Shapes
If InStr(1, shp.Name, "wordart", vbTextCompare) Then
ActiveSheet.Unprotect
shp.Delete
Exit Sub
End If
Next
With ActiveSheet.Shapes.AddTextEffect( _
msoTextEffect1, "D R A F T" & Chr(10) & "ISSUED " _
& Date, "Arial Black", _
24#, msoFalse, msoFalse, Left:=300, Top:=5)
With .Fill
.Visible = msoTrue
.Solid
.ForeColor.SchemeColor = 10
.Transparency = 0.2
End With
With .Line
.Weight = 0.75
.DashStyle = msoLineSolid
.Style = msoLineSingle
.Transparency = 0#
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 0)
.BackColor.RGB = RGB(255, 255, 255)
End With
.LockAspectRatio = msoTrue
.Height = 60#
.Width = 175#
.Rotation = 0#
End With
ActiveSheet.Protect _
DrawingObjects:=True, _
Contents:=False, _
Scenarios:=False
End Sub

--
Regards,
Tom Ogilvy

"JMay" wrote in message
news:hIvLb.70604$hf1.45492@lakeread06...
Below code is working just fine; I 've assigned it to a icon on my
Formatting Toolbar.
At present it is a one-directional Stamping of the Text "DRAFT....
I'de like to be able to click on my button "a second time" and have the

text
"DRAFT..." disappear; then click again, and have it appear,
((Toggle-type)) - Can this be done?
If how, how would I modify (the code) it?
TIA,

Sub DraftStamp()
With ActiveSheet.Shapes.AddTextEffect( _
msoTextEffect1, "D R A F T" & Chr(10) & "ISSUED " & Date,
"Arial Black", _
24#, msoFalse, msoFalse, Left:=300, Top:=5)
With .Fill
.Visible = msoTrue
.Solid
.ForeColor.SchemeColor = 10
.Transparency = 0.2
End With
With .Line
.Weight = 0.75
.DashStyle = msoLineSolid
.Style = msoLineSingle
.Transparency = 0#
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 0)
.BackColor.RGB = RGB(255, 255, 255)
End With
.LockAspectRatio = msoTrue
.Height = 60#
.Width = 175#
.Rotation = 0#
End With
ActiveSheet.Protect _
DrawingObjects:=True, _
Contents:=False, _
Scenarios:=False
End Sub






All times are GMT +1. The time now is 10:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com