如题

解决方案 »

  1.   

    可以用sheet1.cells.item[46,4].comment.text来读取
    但是如果批注为空就会报错,
    如果用if sheet1.cells.item[46,4].comment.text<>''来判断也不行,还是会报错
    不知道怎么判断了?
      

  2.   

    function VarIsDispatchNull(V: Variant): Boolean;
    begin
      Result := False;
      if Not VarIsType(V,varDispatch) then Exit;
      Result := (FindVarData(V)^.VDispatch = Nil);end;
    var
      xlsApp: OleVariant;begin
      xlsApp := CreateOleObject('Excel.Application');
      xlsApp.Visible := true;
      xlsApp.Workbooks.Add;
      xlsApp.ActiveCell.AddComment('测试');
      ShowMessage(BoolToStr( VarIsDispatchNull( xlsApp.ActiveCell.Comment),true));end;