Function Reference

_XLChart_LegendSet

Set properties of the legend.

#Include <ExcelChart.au3>
_XLChart_LegendSet($oChart[, $iPosition = Default[, $iLeft = Default[, $iTop = Default[, $iWidth = Default[, $iHeight = Default[, $bShadow = Default]]]]]])

 

Parameters

$oChart Chart for which the legend properties should be set
$iPosition Optional: Represents the position of the legend on the chart. Please see the XlLegendPosition enumeration (default = Default)
$iLeft Optional: Value in points representing the distance from the left edge of the legend to the left edge of the chart area (default = Default)
$iTop Optional: Value in points representing the distance from the top edge of the legend to the top of the chart area (default = Default)
$iWidth Optional: Value in points representing the width of the legend (default = Default)
$iHeight Optional: Value in points representing the height of the legend (default = Default)
$bFrame Optional: True if the legend has a frame (default = True)
$bShadow Optional: True if the legend has a shadow (default = Default)

 

Return Value

Success: Returns 1
Failure: Returns 0 and sets @error:
    1 - $oChart is no object
    2 - $iLeft is not an integer value
    3 - $iTop is not an integer value
    4 - $iWidth is not an integer value
    5 - $iHeight is not an integer value
    6 - $bShadow is not a boolean value
    7 - $iPosition is not an integer value
    8 - $bFrame is not a boolean value
    9 - Error setting the legend position (position, left or top). Please check @extended for detailed error code
    10 - Error setting the legend width. Please check @extended for detailed error code
    11 - Error setting the legend height. Please check @extended for detailed error code
    12 - Error setting the legend frame. Please check @extended for detailed error code
    13 - Error setting the legend shadow. Please check @extended for detailed error code

 

Remarks

If $iPosition is set parameters $iLeft and $iTop will be ignored

 

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 legend on chart 1 to the bottom, set shadow
; *****************************************************************************
MsgBox(64, "Excel Chart Example Script", "Now changing chart 1 ..." & @CRLF & "Legend to the bottom, width + shadow")
Global $aResult = _XLChart_LegendSet($aExcel[1], $xlLegendPositionBottom, Default, Default, 250, Default, Default, True)
If @error Then MsgBox(64, "Excel Chart Example Script", "Error " & @error & " returned by function '_XLChart_LegendSet' on line " & @ScriptLineNumber)

; *****************************************************************************
; Example 2
; Set legend on chart 2 to the upper right corner, set width, set frame + shadow
; *****************************************************************************
MsgBox(64, "Excel Chart Example Script", "Now changing chart 2 ..." & @CRLF & "Legend to the upper right, frame + shadow")
$aResult = _XLChart_LegendSet($aExcel[2], $xlLegendPositionCorner, Default, Default, Default, Default, True, True)
If @error Then MsgBox(64, "Excel Chart Example Script", "Error " & @error & " returned by function '_XLChart_LegendSet' on line " & @ScriptLineNumber)