XLRunCode
XLRunCode>XLBookHandle,VBACode
Not supported in Macro Scheduler Lite.
This function requires Microsoft Excel to be installed.
Runs the specified valid VBA Code.
Important
For XLRunCode to work 'Trust Access to the VBA project object model' must be enabled in Excel:
In Excel go to File/Options -> Trust Center -> Trust Center Settings -> Macro Settings.
Under 'Developer Macro Settings' enable 'Trust Access to the VBA project object model'
Abbreviation: XRC
See also: XLAddSheet, XLCreate, XLDelCol, XLDelRow, XLDelSheet, XLFind, XLGet, XLGetCell, XLGetSheetDims, XLGetSelectedCell, XLGetSheetNames, XLOpen, XLQuit, XLRun, XLSave, XLSelectRange, XLSetCell, XLSetCellColor, XLSetRangeFormat, XLSheetToArray
Example
XLOpen>%USERDOCUMENTS_DIR%\mybook.xls,1,xlH
//run pure VBA code to set the color
XLRunCode>xlH,ActiveSheet.Range("B12").Interior.Color = vbRed
//could be an entire block of code - let's create a bar chart
LabelToVar>vba_code,theCode
XLRunCode>xlH,theCode
/*
vba_code:
Range("A1:B11").Select
ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
ActiveChart.SetSourceData Source:=Range("Sheet1!$A$1:$B$11")
ActiveSheet.Shapes("Chart 1").IncrementLeft +50
ActiveSheet.Shapes("Chart 1").IncrementTop -30
*/