Lock my shapes from user resizing

tweedle

Well-known Member
Joined
Aug 1, 2010
Messages
1,559
So I'm creating a bunch of shapes via vba that need to maintain their size as created, but allow the user to drag around (move) if need.
I've been digging through shape properties and ShapeNodes but haven't found how to lock the shape from resizing.

I need some direction/examples ... if this is possible.

TIA

Code:
Sub foo()
'basic idea... 
    vleft = 0
    vtop = 0
    gwidth = 40
    gheight = 40
    bwidth = 50
    bheight = 50

    Set shp1 = ActiveSheet.Shapes.AddShape(msoShapeRectangle, vleft + 5, vtop + 5, gwidth, gheight)
    shp1.Fill.ForeColor.RGB = RGB(0, 0, 166)

    Set shp2 = ActiveSheet.Shapes.AddShape(msoShapeRectangle, vleft, vtop, bwidth, bheight)
    shp2.Fill.ForeColor.RGB = RGB(0, 255, 0)
    shp2.ZOrder msoBringToFront
    shp2.ZOrder msoSendBackward

    Dim shpgrp As Shape
    Set shpgrp = ActiveSheet.Shapes.Range(Array(shp1.Name, shp2.Name)).Group
End Sub
 
Hi diddi,

I was refering to the cursor handle not the shape handle. Shapes don't have handles an that's why they can't be easily manipulated with API functions.
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Jaafar;
Thanks for the post.
Conceptually, that's where I was headed with the 'undo buffer'.
I seem to have lost the commandbar object - replaced with the Ribbon - for which I can find no events to trap.

I'll give them another 'confirm before processing' button and sweep through the shapes - that seems the most compatable with my abilities, keeps me out of the GetWindow/GetChildWindow APIs and 'less heavy' than constant monitoring...and xlVersion-safe.

Thanks for the thought/testing you put in.
 
Upvote 0
Jaafar;
Thanks for the post.
Conceptually, that's where I was headed with the 'undo buffer'.
I seem to have lost the commandbar object - replaced with the Ribbon - for which I can find no events to trap.

I'll give them another 'confirm before processing' button and sweep through the shapes - that seems the most compatable with my abilities, keeps me out of the GetWindow/GetChildWindow APIs and 'less heavy' than constant monitoring...and xlVersion-safe.

Thanks for the thought/testing you put in.

I am using excel 2007 but the commandbars events are still there and can be used like in previous versions. You just need to place the code in a Class module such as ThisWorkbook or a sheet module.

I agree with you , regarding not using APIs or constantly monitoring the resizing of the shape by the user .

Good luck.
 
Upvote 0

Forum statistics

Threads
1,213,557
Messages
6,114,293
Members
448,564
Latest member
ED38

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