close

hi all,

i have recorded a macro to produce a square chart containing a square plot.
i wish if it's at all possible to have the square plot centered within the
chart. is there a way to do this? below is the macro routine that i have
recorded in case there is a sub that can be inserted into the macros to
center the plot area within the chart area.

thank you,
jesSub squareGraph()
'
' squareGraph Macro
'

'
On Error GoTo notice

ActiveChart.ApplyCustomType ChartType:=xlUserDefined,
TypeName:=quot;MyScatterquot;
ActiveChart.Parent.Width = 350
ActiveChart.Parent.Height = 350
ActiveChart.PlotArea.Select
Selection.Width = 250
Selection.Height = 250
ActiveChart.Axes(xlValue).Select
Selection.TickLabels.AutoScaleFont = True
With Selection.TickLabels.Font
.Name = quot;Arialquot;
.FontStyle = quot;Regularquot;
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
ActiveChart.Axes(xlValue).AxisTitle.Select
Selection.AutoScaleFont = True
With Selection.Font
.Name = quot;Arialquot;
.FontStyle = quot;Boldquot;
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
ActiveChart.Axes(xlCategory).Select
Selection.TickLabels.AutoScaleFont = True
With Selection.TickLabels.Font
.Name = quot;Arialquot;
.FontStyle = quot;Regularquot;
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
ActiveChart.Axes(xlCategory).AxisTitle.Select
Selection.AutoScaleFont = True
With Selection.Font
.Name = quot;Arialquot;
.FontStyle = quot;Boldquot;
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
Exit Sub
notice: MsgBox (quot;You didn't pick a chart firstquot;)

End Sub

There are a few things you need to keep in mind. First, turn off the font
autoscaling. In your recorded code, the syntax is TextElement.AutoScaleFont
= True; change this to False. Otherwise, the font size will change as you
resize the plot area, causing the plot area to change more than you
intended. Next, keep in mind that the plot area is larger than the rectangle
defined by the axes. It also includes a small margin around this rectangle,
plus the axis ticks and labels. The dimensions of the inner rectangle itself
are read only: you want to change these dimensions, but can only do so by
changing those of the plot area. Remember to allow room for the axis titles
and the chart title.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services - Tutorials and Custom Solutions -
PeltierTech.com/
2006 Excel User Conference, 19-21 April, Atlantic City, NJ
peltiertech.com/Excel/ExcelUserConf06.html
_______

quot;xppuserquot; gt; wrote in message
...
gt; hi all,
gt;
gt; i have recorded a macro to produce a square chart containing a square
gt; plot.
gt; i wish if it's at all possible to have the square plot centered within the
gt; chart. is there a way to do this? below is the macro routine that i have
gt; recorded in case there is a sub that can be inserted into the macros to
gt; center the plot area within the chart area.
gt;
gt; thank you,
gt; jes
gt;
gt;
gt; Sub squareGraph()
gt; '
gt; ' squareGraph Macro
gt; '
gt;
gt; '
gt; On Error GoTo notice
gt;
gt; ActiveChart.ApplyCustomType ChartType:=xlUserDefined,
gt; TypeName:=quot;MyScatterquot;
gt; ActiveChart.Parent.Width = 350
gt; ActiveChart.Parent.Height = 350
gt; ActiveChart.PlotArea.Select
gt; Selection.Width = 250
gt; Selection.Height = 250
gt; ActiveChart.Axes(xlValue).Select
gt; Selection.TickLabels.AutoScaleFont = True
gt; With Selection.TickLabels.Font
gt; .Name = quot;Arialquot;
gt; .FontStyle = quot;Regularquot;
gt; .Size = 8
gt; .Strikethrough = False
gt; .Superscript = False
gt; .Subscript = False
gt; .OutlineFont = False
gt; .Shadow = False
gt; .Underline = xlUnderlineStyleNone
gt; .ColorIndex = xlAutomatic
gt; .Background = xlAutomatic
gt; End With
gt; ActiveChart.Axes(xlValue).AxisTitle.Select
gt; Selection.AutoScaleFont = True
gt; With Selection.Font
gt; .Name = quot;Arialquot;
gt; .FontStyle = quot;Boldquot;
gt; .Size = 8
gt; .Strikethrough = False
gt; .Superscript = False
gt; .Subscript = False
gt; .OutlineFont = False
gt; .Shadow = False
gt; .Underline = xlUnderlineStyleNone
gt; .ColorIndex = xlAutomatic
gt; .Background = xlAutomatic
gt; End With
gt; ActiveChart.Axes(xlCategory).Select
gt; Selection.TickLabels.AutoScaleFont = True
gt; With Selection.TickLabels.Font
gt; .Name = quot;Arialquot;
gt; .FontStyle = quot;Regularquot;
gt; .Size = 8
gt; .Strikethrough = False
gt; .Superscript = False
gt; .Subscript = False
gt; .OutlineFont = False
gt; .Shadow = False
gt; .Underline = xlUnderlineStyleNone
gt; .ColorIndex = xlAutomatic
gt; .Background = xlAutomatic
gt; End With
gt; ActiveChart.Axes(xlCategory).AxisTitle.Select
gt; Selection.AutoScaleFont = True
gt; With Selection.Font
gt; .Name = quot;Arialquot;
gt; .FontStyle = quot;Boldquot;
gt; .Size = 8
gt; .Strikethrough = False
gt; .Superscript = False
gt; .Subscript = False
gt; .OutlineFont = False
gt; .Shadow = False
gt; .Underline = xlUnderlineStyleNone
gt; .ColorIndex = xlAutomatic
gt; .Background = xlAutomatic
gt; End With
gt; Exit Sub
gt; notice: MsgBox (quot;You didn't pick a chart firstquot;)
gt;
gt; End Sub
Thank you Jon. Once I have auto-scaling turned off, the resulting chart's
plot area is more acceptably centered.

jes

quot;Jon Peltierquot; wrote:

gt; There are a few things you need to keep in mind. First, turn off the font
gt; autoscaling. In your recorded code, the syntax is TextElement.AutoScaleFont
gt; = True; change this to False. Otherwise, the font size will change as you
gt; resize the plot area, causing the plot area to change more than you
gt; intended. Next, keep in mind that the plot area is larger than the rectangle
gt; defined by the axes. It also includes a small margin around this rectangle,
gt; plus the axis ticks and labels. The dimensions of the inner rectangle itself
gt; are read only: you want to change these dimensions, but can only do so by
gt; changing those of the plot area. Remember to allow room for the axis titles
gt; and the chart title.
gt;
gt; - Jon
gt; -------
gt; Jon Peltier, Microsoft Excel MVP
gt; Peltier Technical Services - Tutorials and Custom Solutions -
gt; PeltierTech.com/
gt; 2006 Excel User Conference, 19-21 April, Atlantic City, NJ
gt; peltiertech.com/Excel/ExcelUserConf06.html
gt; _______
gt;
gt; quot;xppuserquot; gt; wrote in message
gt; ...
gt; gt; hi all,
gt; gt;
gt; gt; i have recorded a macro to produce a square chart containing a square
gt; gt; plot.
gt; gt; i wish if it's at all possible to have the square plot centered within the
gt; gt; chart. is there a way to do this? below is the macro routine that i have
gt; gt; recorded in case there is a sub that can be inserted into the macros to
gt; gt; center the plot area within the chart area.
gt; gt;
gt; gt; thank you,
gt; gt; jes
gt; gt;
gt; gt;
gt; gt; Sub squareGraph()
gt; gt; '
gt; gt; ' squareGraph Macro
gt; gt; '
gt; gt;
gt; gt; '
gt; gt; On Error GoTo notice
gt; gt;
gt; gt; ActiveChart.ApplyCustomType ChartType:=xlUserDefined,
gt; gt; TypeName:=quot;MyScatterquot;
gt; gt; ActiveChart.Parent.Width = 350
gt; gt; ActiveChart.Parent.Height = 350
gt; gt; ActiveChart.PlotArea.Select
gt; gt; Selection.Width = 250
gt; gt; Selection.Height = 250
gt; gt; ActiveChart.Axes(xlValue).Select
gt; gt; Selection.TickLabels.AutoScaleFont = True
gt; gt; With Selection.TickLabels.Font
gt; gt; .Name = quot;Arialquot;
gt; gt; .FontStyle = quot;Regularquot;
gt; gt; .Size = 8
gt; gt; .Strikethrough = False
gt; gt; .Superscript = False
gt; gt; .Subscript = False
gt; gt; .OutlineFont = False
gt; gt; .Shadow = False
gt; gt; .Underline = xlUnderlineStyleNone
gt; gt; .ColorIndex = xlAutomatic
gt; gt; .Background = xlAutomatic
gt; gt; End With
gt; gt; ActiveChart.Axes(xlValue).AxisTitle.Select
gt; gt; Selection.AutoScaleFont = True
gt; gt; With Selection.Font
gt; gt; .Name = quot;Arialquot;
gt; gt; .FontStyle = quot;Boldquot;
gt; gt; .Size = 8
gt; gt; .Strikethrough = False
gt; gt; .Superscript = False
gt; gt; .Subscript = False
gt; gt; .OutlineFont = False
gt; gt; .Shadow = False
gt; gt; .Underline = xlUnderlineStyleNone
gt; gt; .ColorIndex = xlAutomatic
gt; gt; .Background = xlAutomatic
gt; gt; End With
gt; gt; ActiveChart.Axes(xlCategory).Select
gt; gt; Selection.TickLabels.AutoScaleFont = True
gt; gt; With Selection.TickLabels.Font
gt; gt; .Name = quot;Arialquot;
gt; gt; .FontStyle = quot;Regularquot;
gt; gt; .Size = 8
gt; gt; .Strikethrough = False
gt; gt; .Superscript = False
gt; gt; .Subscript = False
gt; gt; .OutlineFont = False
gt; gt; .Shadow = False
gt; gt; .Underline = xlUnderlineStyleNone
gt; gt; .ColorIndex = xlAutomatic
gt; gt; .Background = xlAutomatic
gt; gt; End With
gt; gt; ActiveChart.Axes(xlCategory).AxisTitle.Select
gt; gt; Selection.AutoScaleFont = True
gt; gt; With Selection.Font
gt; gt; .Name = quot;Arialquot;
gt; gt; .FontStyle = quot;Boldquot;
gt; gt; .Size = 8
gt; gt; .Strikethrough = False
gt; gt; .Superscript = False
gt; gt; .Subscript = False
gt; gt; .OutlineFont = False
gt; gt; .Shadow = False
gt; gt; .Underline = xlUnderlineStyleNone
gt; gt; .ColorIndex = xlAutomatic
gt; gt; .Background = xlAutomatic
gt; gt; End With
gt; gt; Exit Sub
gt; gt; notice: MsgBox (quot;You didn't pick a chart firstquot;)
gt; gt;
gt; gt; End Sub
gt;
gt;
gt;

全站熱搜
創作者介紹
創作者 software 的頭像
software

software

software 發表在 痞客邦 留言(0) 人氣()