I'm not sure if this belongs in Excel or
VB, but I think Excel people may be better equipped to answer it.
I've got a sub in
VB that exports data into an Excel spreadsheet then builds a chart based on that data. Excel is building the chart fine, but the chart is meant to look exactly like an older legacy report from Access so each data series has to be formatted.
What I'm trying to do is change the series marker to xlX, which works in VBA...works in
VB when I hard code it...but doesn't work when I pass it to this sub:
Code:
Public Sub FormatSHChart(xlSheetF As Excel.Worksheet, xlChart As Chart, chartNum As Integer, _
seriesNum, colIndex As Integer, bgColor, fgColor As Integer, _
Marker As String, markerSize As Integer)
With xlSheetF.ChartObjects(chartNum).Chart
With .SeriesCollection(seriesNum)
With .Border
.ColorIndex = colIndex
.Weight = xlMedium
.LineStyle = xlContinuous
End With
.MarkerBackgroundColorIndex = bgColor
.MarkerForegroundColorIndex = fgColor
.MarkerStyle = Marker
.markerSize = markerSize
End With
End With
End Sub
Here's how I call it:
Code:
Call FormatSHChart(xlSheet, xlChart(2), 2, 1, 39, 39, 1, xlX, 5)
It works with line markers like xlTriangle and xlDiamond, but not xlX.
Error message is: 'Run-time error '1004': Unable to set the MarkerStyle property of the Series class'
I googled this but found nothing helpful. Help!