TExcelApplicationでセルにコメントを挿入したいのですが、
型の入力の仕方が分からず困っています。
宜しくお願いします。
ExcelSheet1.Cells.Item[RowY,ColX].Select;
ExcelSheet1.Cells.AddComment('TEST');
だとパラメータが間違っています。となります。
試していませんが、
以下のコードで、コメントは挿入できますか?
ExcelSheet1.Cells[1, 3].AddComment;
ExcelSheet1.Cells[1, 3].Comment.Text(Text:='テスト');
ExcelSheet1.Cells[1, 3]
という記述は認められません。
var
varstr:OLEVariant;
begin
varstr := 'TEST';
ExcelSheet1.Cells.AddComment(varstr);
end;
も無理でした。
試してみました。
ただし(1)…使用したのは中国製のExcelもどきです。(MS Officeを買うお金が無いので。)
ただし(2)…TExcelApplicationのようなタイプライブラリは使ってません。というか用意されてない模様。
なので、動作が異なる可能性が多大にあります。ご参考程度に。
uses
ComObj;
var
Excel: OleVariant;
procedure TForm1.Button1Click(Sender: TObject);
var
ExcelSheet1: OleVariant;
begin
Excel:=CreateOleObject('ET.Application'); // Kingsoft Spreadsheets
Excel.Visible:=True;
Excel.Workbooks.Add;
ExcelSheet1:=Excel.Workbooks[1].WorkSheets[1];
ExcelSheet1.Cells.Item[1,1].Select;
ExcelSheet1.Cells.AddComment('てすと1'); // 無反応
// 以下は成功
ExcelSheet1.Cells[1,2].Select;
Excel.Selection.AddComment('てすと2');
ExcelSheet1.Cells[1,3].Select;
Excel.ActiveCell.AddComment('てすと3');
ExcelSheet1.Cells[1,4].AddComment('てすと4');
ExcelSheet1.Cells.Item[1,5].AddComment('てすと5');
ExcelSheet1.Range['F1'].AddComment('てすと6');
ExcelSheet1.Cells[1,7].AddComment;
ExcelSheet1.Cells[1,7].Comment.Text:='てすと7';
ExcelSheet1.Cells[1,8].AddComment.Text:='てすと8';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Excel.Quit;
Excel:=Unassigned;
end;
Sheet.Cells.Item[1,2].AddComment('AAA');
でいけるかと思います
ありがとうございます。
auさんの記述でできました。
ありがとうございました。