Sub aSmpLine()
  Sheet1.Shapes.AddLine(100, 100, 180, 150).Name = "Line1"
  With [line1].ShapeRange.Line
    .Weight = 3
    .DashStyle = msoLineSolid
    .Style = msoLineThinThin
    .Visible = True
    .ForeColor.SchemeColor = 10
    .BackColor.RGB = RGB(255, 255, 255)
    .EndArrowheadStyle = msoArrowheadTriangle
    .EndArrowheadLength = msoArrowheadLengthMedium
    .EndArrowheadWidth = msoArrowheadWidthMedium
  End With
  MsgBox "Will deleted!"
  [line1].Delete
End Sub请帮忙将以上EXCEL的VBA语句翻译成Delphi语句,急用,谢谢!

解决方案 »

  1.   

    本人是delphi新手,不知道怎么写。请教个问题:sh:=sheet.shapes.addline(288,14.25,720,14.25);线我是画出来了,但我要如何改为箭头呢?如何定义线的粗细呢?线的颜色?
      

  2.   

    我自己搞定了。
    参考代码:
    uses   Comobj;   
        
      var   
              vExcelApp:   Variant;   
      begin   
              vExcelApp   :=   CreateOleObject('Excel.Application');   
              //   显示Excel界面   
              vExcelApp.Visible   :=   true;   
              //   添加一个工作簿   
              vExcelApp.Workbooks.Add;   
        
              //   添加一直线   
              vExcelApp.ActiveSheet.Shapes.AddLine(186.75,   105.75,   323.25,   154.5).Select;   
              vExcelApp.Selection.ShapeRange.Flip(1);   //   msoFlipVertical   
        
              //   添加一箭头   
              vExcelApp.ActiveSheet.Shapes.AddLine(227.25,   177.75,   342.75,   225).Select;   
              vExcelApp.Selection.ShapeRange.Line.EndArrowheadStyle   :=   2;   //   msoArrowheadTriangle   
              vExcelApp.Selection.ShapeRange.Line.EndArrowheadLength   :=   2;   //   msoArrowheadLengthMedium   
              vExcelApp.Selection.ShapeRange.Line.EndArrowheadWidth   :=   2;   //   msoArrowheadWidthMedium   
              vExcelApp.Selection.ShapeRange.Flip(1);   //   msoFlipVertical;   
        
              //   添加一双箭头   
              vExcelApp.ActiveSheet.Shapes.AddLine(265.5,   231,   405,   297.75).Select;   
              vExcelApp.Selection.ShapeRange.Line.BeginArrowheadStyle   :=   2;   //   msoArrowheadTriangle;   
              vExcelApp.Selection.ShapeRange.Line.BeginArrowheadLength   :=   2;   //   msoArrowheadLengthMedium;   
              vExcelApp.Selection.ShapeRange.Line.BeginArrowheadWidth   :=   2;   //   msoArrowheadWidthMedium;   
              vExcelApp.Selection.ShapeRange.Line.EndArrowheadStyle   :=   2;   //   msoArrowheadTriangle;   
              vExcelApp.Selection.ShapeRange.Line.EndArrowheadLength   :=   2;   //   msoArrowheadLengthMedium;   
              vExcelApp.Selection.ShapeRange.Line.EndArrowheadWidth   :=   2;   //   msoArrowheadWidthMedium;   
              vExcelApp.Selection.ShapeRange.Flip(1);   //   msoFlipVertical   
        
              //...   
      end;