Unlocking a chart/graph

vuffe

New Member
Joined
Sep 11, 2017
Messages
4
Hi guys

After searching an hour for the correct code. I am creating a new shape with this code:


Sheets("processtyring").Unprotect Password:="HKV"

ActiveSheet.Shapes.AddChart(xlBarStacked, 150, 150, 1000, 250).Select

Sheets("processtyring").Protect Password:="HKV"


Now i want to mimic the proces of selecting this newly created chart and unlocking it, so users are able to select and edit it, but only parts of the rest of the sheet, which is why it is beeing protected at the end.

I have other shapes/buttons, so it must be only this newly created shape that is getting unlocked. Recording a macro i cant seem to figure out the code.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I made a sheet with a rectangle and an oval, and selected the oval with

ActiveSheet.Shapes("Oval 2").Select
 
Upvote 0
It will have a +1 higher number every time i create the chart so the code must be dynamic. I just want to unlock it so it is editable when i protect the sheet in the end
 
Upvote 0
say you have 20 charts, make A1 = 20, make a new chart, change A1 to 21

then ActiveSheet.Shapes("cells(1,1)").select maybe (not tested)
 
Upvote 0
As far as I know you cannot lock/unlock or otherwise individually protect Objects. You can protect a Worksheet and make sure Objects are locked but when you un-protect ALL objects will be available.

If you only have one drawing object on a worksheet then un-protecting the worksheet will have the effect you want otherwise you will need to find another way to achieve what you want.
 
Upvote 0
But it is possible to manually unlock an object thought properties, and once it is unlocked, i can still select it when I protect the workbook. Thats exactly what i want to do in vba.
 
Upvote 0
Found the solution:

Activechart.Parent.Locked = msoFalse

Thanks for the responses and interest
 
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,736
Members
448,988
Latest member
BB_Unlv

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