[英]Delphi and Excel - Using Autofill
在Delphi 10 / Seattle中,使用Excel 2013 ...我正在尝试:
在“复制计算”步骤中,我正在使用自动填充方法。 我收到错误消息“范围类的自动填充方法失败”。 但我不知道为什么...(请注意,变量aws全局设置为“活动工作表”。)
const
TOTAL_TOUCHES = 'AJ';
...
var
ColumnHeader : OleVariant;
SecondRow : OleVariant;
ColRange : OleVariant;
myAddr, myAddr2 : String;
LastCell : string;
begin
// This routine adds the header 'Total Touches' and then puts an AutoSum in that column for all rows
// Set the header
myAddr := TOTAL_TOUCHES + '1';
ColumnHeader := aws.Range[ myAddr, myAddr];
ColumnHeader.FormulaR1C1 := 'Total Touches';
// Put the first occurance of the Autosum in Row 2
myAddr := TOTAL_TOUCHES + '2';
SecondRow := aws.Range[ myAddr, myAddr];
SecondRow.FormulaR1C1 := '=SUM(RC[-6]:RC[-1])';
SecondRow.Autofill(aws.range['AJ3:AJ50', EmptyParam], xlFillCopy);
一旦工作成功,我将其设置为复制到行中的所有列(与AJ3:AJ50相对,但这是一个小步骤...
我究竟做错了什么?
该文档说, AutoFill
的destination参数是第一个参数,“必须包括源范围”。 在您的情况下,源范围是AJ2,但AJ3:AJ50不包括该单元格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.