VBA WORDART

JL_CAD

Board Regular
Joined
Dec 29, 2002
Messages
65
Currently I have a wordart text that is controlled by a command button. I would like to have the text visible at all times unless a specific checkbox1=1. Also I would like to move the position of the text around. Here is what I have so far:

With ActiveSheet.Shapes.AddTextEffect(msoTextEffect9, "VOID", _
"Arial Black", 36#, msoFalse, msoFalse, _
10, 10)
.ScaleWidth 2, msoFalse, msoScaleFromTopLeft
.ScaleHeight 2, msoFalse, msoScaleFromBottomRight
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.SchemeColor = 0
.Fill.Transparency = 0.5
.Shadow.Transparency = 0.5
.Line.Visible = msoFalse
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
I got most of my questions figured out except for how to get the text to appear at all times unless a checkbox is checked. I tried putting it under a worksheet_change(), but then it only worked when the targeted cell changed and even with that you could still delete the text. Any suggestions?
 
Upvote 0
Change your code so that the shape is assigned to an object variable, like this:

Code:
Public Sh As Shape

Sub Test()
    Set Sh = ActiveSheet.Shapes.AddTextEffect(msoTextEffect9, "VOID", _
    "Arial Black", 36#, msoFalse, msoFalse, _
    10, 10)
    With Sh
        .ScaleWidth 2, msoFalse, msoScaleFromTopLeft
        .ScaleHeight 2, msoFalse, msoScaleFromBottomRight
        .Fill.Visible = msoTrue
        .Fill.Solid
        .Fill.ForeColor.SchemeColor = 0
        .Fill.Transparency = 0.5
        .Shadow.Transparency = 0.5
        .Line.Visible = msoFalse
        .Rotation = 45#
    End With
End Sub

I added rotation at 45 degrees.

Then right click any Toolbar and choose Control ToolBox. Click the CheckBox icon and click and drag to place it on your worksheet. Right click the CheckBox and choose View Code. Paste this into the window on the right:

Code:
Private Sub CheckBox1_Click()
    If CheckBox1.Value = True Then
        Sh.Visible = False
    Else
        Sh.Visible = True
    End If
End Sub

Press Alt+F11 to return to your worksheet and click the Design icon in the Toolbox (top left) to exit design mode.

Run Test then click the CheckBox.
 
Upvote 0
I am getting an error with the current code I have below:

Public Sh As Shape
Sub Test()
Set Sh = ActiveSheet.Shapes.AddTextEffect(msoTextEffect9, "VOID", _
"Arial Black", 36#, msoFalse, msoFalse, _
125, 300)
With Sh
.ScaleWidth 2, msoFalse, msoScaleFromTopLeft
.ScaleHeight 2, msoFalse, msoScaleFromBottomRight
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.SchemeColor = 0
.Fill.Transparency = 0.5
.Shadow.Transparency = 0.5
.Line.Visible = msoFalse
.Rotation = 45#
End With
End Sub

Private Sub CheckBox1_Click()
Dim TheWord As String
Dim Sh As Object
Dim olApp As Object, olMail As Object
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(0)

TheWord = "1234"
If InputBox("Please Enter the verification #", "Password Required") = TheWord Then
CheckBox1.Value = True
'Remove VOID
Sh.Visible = False

'Send to TOOLROOM
'ActiveWorkbook.SendMail Recipients:="ME", Subject:=(Range("E7").Value & " -V-")

'Send message to Originator
olMail.To = Range("F5")
olMail.Subject = (Range("E7") & " in TOOLROOM")
'olMail.Body = Range("a1")
'To display the message use this
olMail.Display
'or to send the message use this
'olMail.Send
'Reactive Excel
AppActivate "Microsoft Excel"

MsgBox ("Verification has been sent to " & Range("F5"))

Else
CheckBox1.Value = False
Sh.Visible = True
MsgBox "Access Denied"
End If
End Sub
 
Upvote 0
I expect that's because you have:

Dim Sh As Object

in your CheckBox1_Click event procedure. That makes it local to thet procedure, but it should be using the Public variable already declared before and set in the Test procedure. So remove that line - I didn't have it in my code.
 
Upvote 0

Forum statistics

Threads
1,221,711
Messages
6,161,450
Members
451,707
Latest member
PedroMoss2268

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