델파이에서 엑셀에 챠트를 그려야 합니다....
VB 스크립트가 아래처럼 됩니다...
<!--CodeS-->
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("Sheet4").Range( _
"B21:B24,D21:D24,F21:F24"), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet4"
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = True
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlRight
ActiveSheet.Shapes("Chart 2").IncrementLeft -218.25
ActiveSheet.Shapes("Chart 2").IncrementTop -90.75
ActiveSheet.Shapes("Chart 2").ScaleWidth 1.2, msoFalse, msoScaleFromTopLeft
ActiveSheet.Shapes("Chart 2").ScaleHeight 0.66, msoFalse, msoScaleFromTopLeft
<!--CodeE-->
이놈을 델파이에서 바꿔서 열심히 코딩중에....
HasAxis부터 막힙니다..... 실행하면 OLE 에러만 나네요....
제가 작성한 코드를 첨부합니당....
<!--CodeS-->
XL := CreateOleObject('Excel.Application');
WB := XL.WorkBooks.Add;
WS := WB.WorkSheets.Add;
CT := XL.Charts.Add;
CT.ChartType := xlLineMarkers;
OleRange := WS.Range['B21:B' + IntToStr(21 + n) + ',' +
'D21:D' + IntToStr(21 + n) + ',' +
'F21:F' + IntToStr(21 + n)];
CT.SetSourceData(OleRange, xlColumns);
CT.Location(xlLocationAsObject, WS.Name);
CT.HasAxis(xlCategory, xlPrimary) := True; <- "여기부터 에러남..."
CT.HasAxis(xlValue, xlPrimary) := True;
CT.Axes(xlCategory, xlPrimary).HasAxis := True;
CT.Axes(xlValue, xlPrimary).HasAxis := True;
CT.Axes(xlCategory, xlPrimary).CategoryType := xlCategoryScale;
CT.Axes(xlCategory).HasMajorGridlines := False;
CT.Axes(xlCategory).HasMinorGridlines := False;
CT.Axes(xlValue).HasMajorGridlines := True;
CT.Axes(xlValue).HasMinorGridlines := False;
CT.HasLegend := True;
<!--CodeE-->
소스를 그냥 올려서 참...그렇지만...
혹시 이런거 해보신분 도움 부탁드립니다....^^