Unlocking shape/textbox in VBA

UK_Kiwi

New Member
Joined
Nov 8, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have created a VBA code via record macro which inserts a shape with text into a worksheet as a note to other users. The code works perfectly, however, I would like to protect the sheet so users don't delete formulas etc. When I protect the sheet, the activated Macro works, however the text box can not be deleted once the user has read it. The vba code already unlocks/locks the sheet to run certain aspects of the code, and now I need to figure out how and where I need to add an unlock function to the shape code. I have copied the section of my code that should be relevant.

ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 286.0714173228, 300 _
, 559.2857480315, 289.2857480315).Select
Selection.ShapeRange.TextFrame2.TextRange.Font.Size = 20
Selection.ShapeRange.TextFrame2.TextRange.Font.Bold = msoTrue
Selection.ShapeRange.TextFrame2.VerticalAnchor = msoAnchorMiddle
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = _
"1. Save as new file version number (xxxxx.v?.0)" & Chr(13) & "" & Chr(13) & "2. Turn on Auto Save" & Chr(13) & "" & Chr(13) & "3. Paste new Procim download in detailed breakdown Tab ready for next issue" & Chr(13) & "" & Chr(13) & "4. Delete this text box" & Chr(13) & "" & Chr(13) & "5. Repeat for each estimate version"
Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 48).ParagraphFormat. _
FirstLineIndent = 0
With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 48).Font
.Bold = msoTrue
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 0, 0)
.Fill.Transparency = 0
.Fill.Solid
.Size = 20
.Name = "+mn-lt"
End With

Code in between sets colour and font to text

With Selection.ShapeRange.Line
.Visible = msoTrue
.Weight = 4.5
End With
Selection.ShapeRange.ScaleWidth 1.2030651017, msoFalse, msoScaleFromTopLeft
Worksheets("Budget Summary").Protect "*****"
End Sub

Advice and guidance appreciated for a long time reader, first time poster

Thanks

SW
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi @UK_Kiwi Welcome to the MrExcel forum. Please accept my warmest greetings and sincere hope that all is well.

Change this line:
VBA Code:
Worksheets("Budget Summary").Protect "*****"


For this:
VBA Code:
Worksheets("Budget Summary").Protect "*****", DrawingObjects:=False

----- --
Let me know the result and I'll get back to you as soon as I can.
Sincerely
Dante Amor
----- --
 
Upvote 0
Solution
Hi Dante,

Absolutely brilliant and makes perfect sense that it should go there!! Ha ha ha.

Thank you

SW
 
Upvote 0

Forum statistics

Threads
1,215,072
Messages
6,122,968
Members
449,095
Latest member
Mr Hughes

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