Why can you only access a shape properties when the sheet with the shape on is activated?

Johnny C

Well-known Member
Joined
Nov 7, 2006
Messages
1,069
Office Version
  1. 365
Platform
  1. Windows
Just idly curious. I can't access a shapes properties unless the sheet is activated. I'm guessing the process of activating the sheet loads the sheet shapes into accessible memory, but why? Are the sheet's shapes and properties stored in an abbreviated form that is only expanded to accessible memory when the sheet is activated?

Or should I be accessing a worksheet shape cache to get the shapes (like the pivot table cache)
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
You can do it like this:
Sheets(1).Shapes("Oval 1").Fill.ForeColor.RGB = RGB(0, 0, 255)
 
Upvote 0
Does it only work with the sheet codenumber?

When I reference a sheet shape e.g.

Code:
strHTMLText = Workbooks(strThisWB).wkSettings.Shapes("strEmailText").Text
it gives an error, Error 438, Object doesn't support this property or method
I've tried all sorts.

Code:
Workbooks(strThisWB).Activate
wkSettings.Activate
strHTMLText = ActiveSheet.Shapes("strEmailText").Text
works fine, but
Code:
strHTMLText = Workbooks(strThisWB).wkSettings.Shapes("strEmailText").Text
bombs
 
Upvote 0
What is wkSettings? A variable, or sheet code name? Either way, you can't use Workbooks(strThisWB).wkSettings since a workbook doesn't have a wkSettings property, and you don't need to since it refers to a specific worksheet anyway so it's just:

Code:
strHTMLText = wkSettings.Shapes("strEmailText").Text
 
Last edited:
Upvote 0
wkSettings is a sheet code name.

It's nestled amongst code for XL/PP & Word so I'll have a play around with it.
 
Upvote 0
If it's a code name, it would only work for a sheet in the workbook with the code (unless you'd set a reference to another workbook, in which case you could use projectname.codename to refer to a sheet in that workbook) so there is no need to qualify it anyway.
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,183
Members
449,071
Latest member
cdnMech

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