Set properties of a title. This can be the chart or any axis title.
#Include <ExcelChart.au3>
_XLChart_TitleSet($oObject[, $sCaption = Default[, $bShadow = Default[, $iLeft = Default[, $iTop = Default[, $iHorizontalAlignment = Default[, $iVerticalAlignment = Default[, $iOrientation = Default[, $bIncludeInLayout = Default]]]]]]]])
Parameters
$oObject | Title object (e.g. $oChart.ChartTitle or $oChart.Axes([$xlCategory|$xlValue|$xlSeriesAxis]).AxisTitle) |
$sCaption | Optional: String representing the title text. "" removes an existing title caption (default = Default) |
$bShadow | Optional: Boolean that determines if the object has a shadow (default = Default) |
$iLeft | Optional: Value in points representing the distance from the left edge of the title to the left edge of the chart area (default = Default) |
$iTop | Optional: Value in points representing the distance from the top edge of the title to the top of the chart area (default = Default) |
$iHorizontalAlignment | Optional: Variant representing the horizontal alignment. A subset of the XlHAlign enumeration (default = Default). See the Remarks |
$iVerticalAlignment | Optional: Variant representing the vertical alignment (default = Default) |
$iOrientation | Optional: Variant representing the text orientation (default = Default) |
$bIncludeInLayout | Optional: True if a chart or axis title will occupy the chart layout space when a chart layout is being determined (default = Default) |
Return Value
Success: Returns 1
Remarks
The value of $iHorizontalAlignment can be one of the following out of the XlHAlign enumeration:
Related
Example
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
#include-once
#include <ExcelChart.au3>
; *****************************************************************************
; Create example environment
; *****************************************************************************
Global $aExcel = _XLChart_Example(True, 0, 0, -1, -1)
If @error = 2 Then Exit MsgBox(16, "Excel Chart Example Script", "The installed Excel version is not supported by this UDF!" & @CRLF & "Version must be >= 12 (Excel 2007).")
If @error <> 0 Then Exit MsgBox(16, "Excel Chart Example Script", "Error " & @error & " returned by _XLChart_Example on line " & @ScriptLineNumber)
; *****************************************************************************
; Example 1
; Set chart title chart 1: Change text, shadow, horizontal alignment, orientation
; *****************************************************************************
MsgBox(64, "Excel Chart Example Script", "Now changing chart 1 ..." & @CRLF & "Set chart title, shadow, horizontal alignment, orientation to 45 degree")
Global $aResult = _XLChart_TitleSet($aExcel[1].ChartTitle, "Test Chart Title", True, Default, Default, $xlDistributed, Default, 45)
If @error Then MsgBox(64, "Excel Chart Example Script", "Error " & @error & " returned by function '_XLChart_TitleSet' on line " & @ScriptLineNumber)
; *****************************************************************************
; Example 2
; Change x-Axis title of chart 2: Change text, move it to position 45 in the chart area
; *****************************************************************************
MsgBox(64, "Excel Chart Example Script", "Now changing chart 2 ..." & @CRLF & "X-Axis title change text, move it to position 45 in the chart area")
$aResult = _XLChart_TitleSet($aExcel[2].Axes($xlCategory).AxisTitle, "Test X-Axis Title", Default, 45)
If @error Then MsgBox(64, "Excel Chart Example Script", "Error " & @error & " returned by function '_XLChart_TitleSet' on line " & @ScriptLineNumber)
; *****************************************************************************
; Example 3
; Remove chart title chart 2
; *****************************************************************************
MsgBox(64, "Excel Chart Example Script", "Now changing chart 2 ..." & @CRLF & "Removing chart title")
$aResult = _XLChart_TitleSet($aExcel[2].ChartTitle, "")
If @error Then MsgBox(64, "Excel Chart Example Script", "Error " & @error & " returned by function '_XLChart_TitleSet' on line " & @ScriptLineNumber)
; *****************************************************************************
; Example 4
; Remove y-axis title of chart 1
; *****************************************************************************
MsgBox(64, "Excel Chart Example Script", "Now changing chart 1 ..." & @CRLF & "Removing y-axis title")
$aResult = _XLChart_TitleSet($aExcel[1].Axes($xlValue).Axistitle, "")
If @error Then MsgBox(64, "Excel Chart Example Script", "Error " & @error & " returned by function '_XLChart_TitleSet' on line " & @ScriptLineNumber)