LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Moving a shape with text inside without editing text

Hi Dan,

In order to lock the text, the worksheet must be protected. The code
below will unprotect the sheet, add a shape to it, add the text, then
lock the text while still allowing you to move the shape around, and
finally re-protect the sheet.

Sub AddLockedTextShape()

Dim ws As Worksheet
Dim shp As Shape
Dim rng As Range
Dim w As Single
Dim h As Single

w = 48# ' standard cell width
h = 12.75 ' standard cell height

Set ws = ActiveSheet
Set rng = ws.Range("C3")

ws.Unprotect ' optional: use a password

Set shp = ws.Shapes.AddShape(msoShapeRectangle, rng.Left, rng.Top,
w, 4 * h)
shp.TextFrame.Characters.Text = "My Text"
shp.Select

' These don't have any affect unless the sheet is protected
With Application.Selection
.LockedText = True
.Locked = False
End With

ws.Protect

Set rng = Nothing
Set shp = Nothing
Set ws = Nothing

End Sub


HTH,

Nick Hebb
BreezeTree Software
http://www.breezetree.com

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
searching for text inside a text box wildetudor Excel Discussion (Misc queries) 0 January 21st 09 02:16 PM
How to embed large number of variables in text inside a text box? Riva Chase Excel Discussion (Misc queries) 0 October 30th 07 01:42 AM
Cutting and pasting large variable text into a text box shape usin AJL Excel Programming 0 October 30th 06 06:54 PM
How to make the text inside Text Box upside down? Kataro Excel Discussion (Misc queries) 1 December 21st 05 03:38 PM
Editing text in text box grouped within a trapezoid Linking to specific cells in pivot table Excel Programming 11 August 16th 05 09:17 AM


All times are GMT +1. The time now is 03:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"