Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Chart - Title Widths
Does anyone know how to find the width of a title/axis title? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
The charttitle, along with the other labelling items in a chart, do not expose the Width or Height properties. Try this workaround. (Beware of word wrapping). '------------------ Sub X MsgBox GetChartTitleWidth(ActiveChart) End Sub Function GetChartTitleWidth(MyChart As Chart) As Single Dim sngOrigLeft As Single If MyChart.HasTitle Then sngOrigLeft = MyChart.ChartTitle.Left MyChart.ChartTitle.Left = MyChart.ChartArea.Left + MyChart.ChartArea.Width GetChartTitleWidth = (MyChart.ChartArea.Width - MyChart.ChartArea.Left) - MyChart.ChartTitle.Left MyChart.ChartTitle.Left = sngOrigLeft End If End Function '------------------ It uses the fact that the chart title can not be more beyond the area of the chart. The routine tries and then uses the gap between the edge and the new Left position to determine the width. Should be close enough. Obvioulsy the same technique can be applied to get the height wrote: Chart - Title Widths Does anyone know how to find the width of a title/axis title? -- Cheers Andy http://www.andypope.info |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You have to do this indirectly, since as you've learned, the charttitle
object exposes no width (or height) property to VBA. But if you move it as far to the right as possible, then the width of the chart minus the left position of the charttitle is equal to the charttitle width. activechart.ChartTitle.left = activechart.ChartArea.width ChartAreaWidth = activechart.ChartArea.width - _ activechart.ChartTitle.left Some simple experiments with the legend, which does expose its width, indicates that the width calculated above is about 3 points too large. To center the chart title, use this: activechart.ChartTitle.left = activechart.ChartArea.width activechart.ChartTitle.left = activechart.ChartTitle.left/2 - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services http://PeltierTech.com/Excel/Charts/ _______ wrote: Chart - Title Widths Does anyone know how to find the width of a title/axis title? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to hide a chart title, but keep the title in the chart | Charts and Charting in Excel | |||
Possible to change chart title and label box widths? | Charts and Charting in Excel | |||
Excel chart - how to assign the file name in the chart title? | Charts and Charting in Excel | |||
Pasting Objects into Chart title and Axis title | Charts and Charting in Excel | |||
Bar Chart Bar Widths | Charts and Charting in Excel |