Set Text in Embedded TextBox in Chart Embedded in Protected Sheet: 2007 vs 2016

jmcafee

New Member
Joined
Oct 7, 2018
Messages
1
I have a textbox (VBA shape type 17) embedded in a chart embedded in a worksheet that is protected:
Sheet11.ChartObjects(1).Chart.Shapes(1)

I want to assign calculated text to the textbox using VBA.

With the worksheet protected, I can successfully set the text in Excel 2016 using this (and several other variations of syntax):
Sheet11.ChartObjects(1).Chart.Shapes(1).TextFrame2.Textrange.Text = "Textbox Text"

The same code works in Excel 2007 only if the worksheet is unprotected. With the sheet protected, runtime error 1004 "Unable to set the Text Property" is generated, even if the parent chart Locked property is False.

In both 2007 and 2016 I cannot set the Locked property of the embedded textbox. This property is not available in the UI, nor can it be assigned in VBA. The Shapes(1).Locked property always returns True, and remains True even if I assign the property to False.

Unprotecting the worksheet first, or assigning the text to the contents of a cell both work, but are less desirable solutions (for various reasons). The inability to set the text when protected seems like a bug in Excel 2007.

Is my VBA code somehow wrong?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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