答案好像就在你代码里吧?$oExcel.Visible = True
$oExcel.WorkBooks.Add
$oExcel.Cells(1, 1).Value = "A1赋值"
_add_comment()
MsgBox(0, '备注内容1', $oExcel.Cells(1, 1).Comment.Text)
Sleep(5000)
_add_comment()
MsgBox(0, '备注内容2', $oExcel.Cells(1, 1).Comment.Text)
Func _add_comment()
If StringLen($oExcel.Cells(1, 1).Comment.Text) = 0 Then
$var = "首次添加批注"
$oExcel.Cells(1, 1).AddComment($var)
ConsoleWrite('1')
Else
$var = "再次追加批注"
$var = $oExcel.Cells(1, 1).Comment.Text & @CRLF & $var
$oExcel.Cells(1, 1).Comment.Text($var)
ConsoleWrite('2')
EndIf
EndFunc
|