VBScript を使用して、Excel 2003 のデータの列から折れ線散布図を作成しています。問題なく表示されますが、背景色や軸ラベルなど、グラフのプロパティの一部を編集したいと考えています。これを Excel で手動で行い、マクロを記録すると、次の VBA コードが得られました。
ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection.Interior
.ColorIndex = 2
.PatternColorIndex = 1
.Pattern = xlSolid
End With
ActiveChart.Axes(xlCategory).Select
With Selection.TickLabels
.ReadingOrder = xlContext
.Orientation = 45
End With
ActiveChart.Axes(xlValue).AxisTitle.Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.ReadingOrder = xlContext
.Orientation = xlHorizontal
End With
ActiveChart.ChartArea.Select
End Sub
これは VBA では問題ないように見えますが、VBScript への変換に問題があります。どのように始めればよいですか?これは現時点での私のコードです:
Set objChart = objExcel.Charts.Add()
With objExcel.ActiveChart
.ChartType = xlXYScatterLinesNoMarkers
.SeriesCollection(1).Interior.Color = RGB(255, 0, 0)
.HasTitle = True
.ChartTitle.Text = "usage"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Time"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "units"
.HasLegend = False
.SetSourceData objWorksheet.Range("E1","F" & LastRow), xlColumns
.SetSourceData objWorksheet.Range("E1:F200"), xlColumns
End With
行.SeriesCollection(1).Interior.Color = RGB(255, 0, 0)により、「Interior クラスの色プロパティを設定できません」というエラーが発生します。.Activechart のすぐ下で .SeriesCollection を呼び出すべきではないと思います。助言がありますか?この時点で、グラフの背景色を白に変更し、x 軸のラベルを 45 度回転させることができれば幸いです。
前もって感謝します。