Show code in...     

  

 

Object Model ExcelApplication Worksheets Worksheet Cells Cell Range
Charts Chart SeriesCollection Series 3DProperties Axis ChartFrame Line Area
PivotField PivotFields PivotTable PivotTables
Style Characters Font Pictures Picture DocumentProperties PageSetup


The ChartFrame Object (IChartFrame)

ChartArea, DataTable, Legend, LabelFrame, PlotArea, and Title are ChartFrame objects.

ChartFrame Methods and Properties

ChartFrame Methods and Properties
Area

Returns an Area object, representing the area of the ChartFrame object (ChartArea, Legend, LabelFrame, PlotArea, or Title). The properties of Area are AreaFormatting, BackgroundColor, ForegroundColor, and Pattern.

The following sets the pattern of a ChartArea object to Trellis.


[VBScript]
Property Area As SAArea (read-only)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- IChartFrame interface can be used to format 
'--- certain object on a chart
'--- Here, use IChartFrame to format the chart's legend
MyChart.Legend.Area.BackgroundColor = RGB(255,0,0)


Top

Border

Returns a Line object, representing the border of the ChartFrame object (ChartArea, Legend, LabelFrame, PlotArea, or Title). The properties of Area are LineColor, LineFormatting, LineStyle, and LineWeight.

The following sets a ChartArea object's border color to red.


[VBScript]
Property Border As SALine (read-only)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
		0, 1, 1, 10, 10)

'--- Format the chart area's border color with the Border property
MyChart.ChartArea.Border.LineColor = RGB(255,0,0)


Top

HasShadow

When HasShadow is set to True, the ChartFrame object will have a shadow effect. HasShadow is set to False by default.

The following will display the chart legend with a shadow effect.


[VBScript]
Property HasShadow As Boolean (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			 0, 1, 1, 10, 10)

'--- Show the chart's legend with a shadow effect
MyChart.Legend.HasShadow = True


Top

Height

Height has two definitions: one for ChartArea, and another for all other ChartFrame objects.

  • For ChartArea: Specifies the ChartArea's vertical offset from its lower right corner row. If the value of Height is negative, the ChartArea's bottom border will be offset upward. If the value of Height is positive, the ChartArea's bottom border will be offset downward.
    
    [VBScript]
    Property Height As Long (read/write)
    
    		
  • For all other ChartFrame objects: Height is the x coordinate of the lower left corner of the ChartFrame, in units of 1/4000 of the ChartArea.

Note: LegendLocation and the pair of Chartframe properties Height and Width are mutually exclusive. Use either LegendLocation or Height and Width.

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Display the ChartArea offset upward of its bottom row
MyChart.ChartArea.Height = -200


Top

Number

LabelFrame property. Sets the display format of label numbers. For a complete list of Number codes, see Formatting Codes. The following example demonstrates assigning the percentage format to a LabelFrame.


[VBScript]
Property Number As Variant (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
		0, 1, 1, 10, 10)

'--- Set the format for label numbers to 0.00%
MyChart.ChartArea.Number = 10


Top

Text

Sets or returns the text of a Title ChartFrame object. Text is a title's default property, so you can assign the title text by either of the following methods.


[VBScript]
In VBScript, this is the default property for the IChartFrame object.

Property Text As String (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Set the title string for the chart
MyChart.Title.Text = "Chart Title Here"


Top

TextFont

Sets or returns a Font object representing a ChartFrame's font. The properties of TextFont are, Bold, Charset, Color, Italic, Name, QueryFontDisp, Size, Strikethrough, Subscript, Superscript, Underline, and Weight.

The following will set the legend's font to Tahoma.


[VBScript]
Property TextFont As SAFont (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart, MyTitleFont
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Create a new font
Set MyTitleFont = XlwApp.CreateFont()
MyTitleFont.Name = "Tahoma"
MyTitleFont.Bold = True

'--- Set the title font for the chart
MyChart.Title.TextFont = MyTitleFont


Top

TextHorizontalAlignment

Sets or returns the horizontal alignment of text in a ChartFrame. Set TextHorizontalAlignment to an ASXTextAlignment value, by name or number:

ASXTextAlignment Values
saxlLeft1
saxlsCenter2
saxlRight3
saxlsJustify4

The following will display the legend text horizontally centered.


[VBScript]
Property TextHorizontalAlignment As ASXTextAlignment (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Set the text horizontal alignment 
'--- for the chart title to Justify
MyChart.Title.TextHorizontalAlignment = saxlsJustify


Top

TextRotationAngle

Sets or returns the rotation angle of text in a ChartFrame.

The following will rotate the chart's title text 45 degrees counterclockwise.


[VBScript]
Property TextRotationAngle As Long (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Rotate the title text 45 degrees counterclockwise
MyChart.Title.TextRotationAngle = 45


Top

TextVerticalAlignment

Sets or returns the vertical alignment of text in a ChartFrame. The values of TextVerticalAlignment are,

saxlsTop1
saxlsCenter2
saxlsBottom3
saxlsJustify4


[VBScript]
Property TextVerticalAlignment As ASXTextAlignment (read/write)

		

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Set the text vertical alignment 
'--- for the chart title to Bottom
MyChart.Title.TextVerticalAlignment = saxlsBottom


Top

Width

Width has two definitions: one for ChartArea, and another for all other ChartFrame objects.

  • For ChartArea: Specifies the ChartArea's horizontal offset from its lower right corner column. If the value of Width is negative, the ChartArea's right border will be offset to the left. If the value of Width is positive, the ChartArea's right border will be offset to the right. The following example will display the ChartArea offset to the right of its right-border column.
    
    [VBScript]
    Property Width As Long (read/write)
    
    		
  • For all other ChartFrame objects: Width is the y coordinate of the lower left corner of the ChartFrame, in units of 1/4000 of the ChartArea.

Note: LegendLocation and the pair of Chartframe properties Height and Width are mutually exclusive. Use either LegendLocation or Height and Width.

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'--- Display the ChartArea offset to 
'--- the right of its right-border column
MyChart.ChartArea.Width = 200


Top

X

X has two definitions: one for ChartArea, and another for all other ChartFrame objects.

  • For ChartArea: Specifies the ChartArea's horizontal offset from its upper left corner column. If the value of X is negative, the ChartArea's left border will be offset to the left. If the value of X is positive, the ChartArea's left border will be offset to the right. The following example will display the ChartArea offset to the right of its left-border column.
    
    [VBScript]
    Property X As Long (read/write)
    
    		
  • For all other ChartFrame objects: X is the x coordinate of the upper right corner of the ChartFrame, in units of 1/4000 of the ChartArea.

Note: X is not a property of Legend.

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
		0, 1, 1, 10, 10)

'--- Display the ChartArea offset to the 
'--- right of its left-border column
MyChart.ChartArea.X = 200


Top

Y

Y has two definitions: one for ChartArea, and another for all other ChartFrame objects.

  • For ChartArea: Specifies the ChartArea's vertical offset from its upper left corner row. If the value of Y is negative, the ChartArea's top border will be offset upward. If the value of Y is positive, the ChartArea's top border will be offset downward. The following example will display the ChartArea offset downward of its upper row.
    
    [VBScript]
    Property Y As Long (read/write)
    
    		
  • For all other ChartFrame objects: Y is the y coordinate of the upper right corner of the ChartFrame, in units of 1/4000 of the ChartArea.

Note: Y is not a property of Legend.

Example:



[VBScript]

'--- Create an instance of ExcelWriter and 
'--- add a column chart to worksheet #1
Dim XlwApp, WrkSht, MyChart
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
Set MyChart = WrkSht.Charts.Add(saxlsColumnChart, _
			0, 1, 1, 10, 10)

'---Display the ChartArea offset downward of its upper row
MyChart.ChartArea.Y = 200


Top



Object Model ExcelApplication Worksheets Worksheet Cells Cell Range
Charts Chart SeriesCollection Series 3DProperties Axis ChartFrame Line Area
PivotField PivotFields PivotTable PivotTables
Style Characters Font Pictures Picture DocumentProperties PageSetup


Copyright © 2005, SoftArtisans, Inc.