Hallo miteinander
Wenn ich das Diagramm erstelle, vertauscht es mir immer die Achsen. Die erste Achse im Range sollte doch die X-Achse sein? Jedenfalls ist es so beim Makro.
Der relevante Code
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39:
| procedure TForm1.Button1Click(Sender: TObject); var GraphSheet: Variant; RowCount: Real; begin GraphSheet := CreateOLEObject('Excel.Application'); GraphSheet.Workbooks.Add; GraphSheet.Cells[1,1] := 'Zeit'; GraphSheet.Cells[1,2] := 'Ist-Wert'; GraphSheet.Cells[1,3] := 'Soll-Wert'; GraphSheet.Cells[1,4] := 'Diff-Wert'; GraphSheet.Range['A1:D1'].HorizontalAlignment := xlHAlignCenter; RowCount := 2; GraphSheet.Visible := true; Repeat TimeLabel.Caption := FloatToStr(RowCount-1); GraphSheet.Cells[RowCount,1] := TimeLabel.Caption; GraphSheet.Cells[RowCount,2] := RowCount - 40; GraphSheet.Cells[RowCount,3] := RowCount + 40; GraphSheet.Cells[RowCount,4] := RowCount; RowCount := RowCount + 1; Until RowCount >= 100; GraphSheet.Range['A2:D'+FloatToStr(RowCount-1)]; GraphSheet.Charts.Add; GraphSheet.ActiveChart.ChartType := xlXYScatterSmooth; GraphSheet.ActiveChart.SetSourceData(GraphSheet.WorkSheets['Tabelle1'].Range['A2:D'+FloatToStr(RowCount)], xlColumns); GraphSheet.ActiveChart.HasTitle := true; GraphSheet.ActiveChart.ChartTitle.Characters.Text := 'Temperaturverlauf'; GraphSheet.ActiveChart.Axes(XlCategory, xlPrimary).HasTitle := True; GraphSheet.ActiveChart.Axes(XlCategory, xlPrimary).AxisTitle.Characters.Text := 'Zeit'; GraphSheet.ActiveChart.Axes(XlValue, xlPrimary).HasTitle := True; GraphSheet.ActiveChart.Axes(XlValue, xlPrimary).AxisTitle.Characters.Text := 'Tempereature'; GraphSheet.ActiveChart.Axes(xlCategory).HasMajorGridLines := false; GraphSheet.ActiveChart.Axes(xlCategory).HasMinorGridLines := false; GraphSheet.ActiveChart.Axes(xlValue).HasMajorGridLines := true; GraphSheet.ActiveChart.Axes(xlValue).HasMinorGridLines := false; end; |
So sieht das ganze beim Makro aus.
Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30:
| Sub Makro1() ' ' Makro1 Makro ' Makro am 06.09.2005 von Mitarbeiter aufgezeichnet '
' Range("A1:C9").Select Charts.Add ActiveChart.ChartType = xlXYScatterSmooth ActiveChart.SetSourceData Source:=Sheets("Tabelle1").Range("A1:C9"), PlotBy _ :=xlColumns ActiveChart.Location Where:=xlLocationAsObject, Name:="Tabelle1" With ActiveChart .HasTitle = True .ChartTitle.Characters.Text = "Temperaturverlauf" .Axes(xlCategory, xlPrimary).HasTitle = True .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Zeit" .Axes(xlValue, xlPrimary).HasTitle = True .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Temperatur" End With With ActiveChart.Axes(xlCategory) .HasMajorGridlines = False .HasMinorGridlines = False End With With ActiveChart.Axes(xlValue) .HasMajorGridlines = True .HasMinorGridlines = False End With End Sub |
VB igitt igitt
Ich hoffe es kann mir jemand helfen und bedanke mich schon mal
Gruss Selecta