ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How separate text boxes from pictures in the same worksheet by code? (https://www.excelbanter.com/excel-programming/315886-how-separate-text-boxes-pictures-same-worksheet-code.html)

Marie J-son

How separate text boxes from pictures in the same worksheet by code?
 
Hi everyone,
I have PICTURES (created by "CopyPicture method" by the way) embedded in a
excel worksheet and I want to allow to copy them. I ALSO in the same sheet
have TEXT BOXES and I want to protect their text. I tried with
drawingobjects.select, but found out that a picture is a drawing object.

Is there a specified objecttype just for text boxes I can use to protect
just them? [Sheet1.TextBoxes.Protect = True would be nice..but doesn't
exist.]

I DON'T want to change from text boxes to merged cells , I have just left
that track of several reasons. I want my boxes protected (and protected
cells in the sheet) and allow copy the pictures

/BEST REGARDS
and thanks in advance



Gunnar Johansson

How separate text boxes from pictures in the same worksheet by code?
 
Here is the solution

Sub LockTextBoxNotPic()
Dim myShape As Shape
For Each myShape In ActiveSheet.Shapes
If myShape.Type = msoTextBox Then
myShape.Locked = True
Else
If myShape.Type = msoPicture Then
myShape.Locked = False
End If
End If
Next myShape
End Sub


/Regards


"Marie J-son" skrev i meddelandet
...
Hi everyone,
I have PICTURES (created by "CopyPicture method" by the way) embedded in a
excel worksheet and I want to allow to copy them. I ALSO in the same sheet
have TEXT BOXES and I want to protect their text. I tried with
drawingobjects.select, but found out that a picture is a drawing object.

Is there a specified objecttype just for text boxes I can use to protect
just them? [Sheet1.TextBoxes.Protect = True would be nice..but doesn't
exist.]

I DON'T want to change from text boxes to merged cells , I have just left
that track of several reasons. I want my boxes protected (and protected
cells in the sheet) and allow copy the pictures

/BEST REGARDS
and thanks in advance





All times are GMT +1. The time now is 09:32 PM.

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