Detect Text Box covering Chart Element

pbornemeier

Well-known Member
Joined
May 24, 2005
Messages
3,915
I have some code that adds a text box to a column chart at a fixed location from the top and left of the chart. Currently, if the text box covers the top end of any column, I manually reposition it so that is either in an area at the top of the chart where no bars extend, or to the lower half of the chart where all of the bars would go past the top of the text box.

Is there any way to detect whether a text box (or any shape for that matter) overlaps one or more chart elements (i.e. column, legend, title) or for that matter another shape or text box?

Is there a way to determine the location of a "clear area" (of specified size) where a text box could be placed?

I'm sure there could be some cases where the end of a bar must be covered, but if that happens, I will have to live with it.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
It looks like the Excel4 Macro GET.CHART.ITEM could be used to accomplish this.
Rich (BB code):
GET.CHART.ITEM(x_y_index, point_index, item_text)
  • <TT>x_y_index</TT> is 1 to return the x position and 2 to return the y position.
  • <TT>point_index</TT> depends on the item we're looking at, but is a number from 1 to 8 to identify a specific vertex within the item. For example, 2 is the upper middle of any rectangular item, such as a column in a column chart.
  • <TT>item_text</TT> identifies the item we're interested in, such as "Plot" for the plot area, or "S2P4" for the fourth data point in the second series in the chart. If item_text is omitted then the selected item information is returned.
Partial documentation here: http://www.informit.com/articles/article.aspx?p=374498&seqNum=2
I will keep looking for a full list of the valid values for the 3rd parameter (Known valid items include: Plot, Legend, Chart, S2P4 (Series 2, Point 4)
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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