范围(选择,选择。结束(xlDown))。选择

时间:2013-12-25 17:07:23

标签: excel perl excel-vba win32ole vba

如何将以下excel vba语句转换为perl win32 :: ole语句?

Range(Selection, Selection.End(xlDown)).Select

我转换如下,但不起作用:

my $Excel = CreateObject OLE "Excel.Application";
my $SecondSht = $Book->ActiveSheet;
$SecondSht->Range("P2")->Select();
$SecondSht->Range({$Excel->Selection(), {$Excel->Selection()->End({xlDown})})->Select(); #fails at this statement
$Excel->Selection->Copy;
$SecondSht->Range({"Q2"})->Select;
$SecondSht->Paste;

1 个答案:

答案 0 :(得分:1)

我得到了答案!

$SecondSht->Range($SecondSht->Range("P2"), $SecondSht->Range("P2")->End(xlDown))->Select();
$Excel->Selection->Copy;
$SecondSht->Range("Q2")->Select();
$SecondSht->Paste;