Charting in VBA problem

J

jmacclure

I'm trying to create a form code that will make a chart and display i
in the form and am having some trouble with the code for creating th
chart. I am using OfficeXP.

Here is the code section that I am having problems with and the issu
written behind.



Dim myChtObj As ChartObject
Dim myNewSeries1 As Series
Dim myXValues As Range
Dim myYValues1 As Range
Dim myName1 As Range
Dim myName2 As String
Dim myChtTitle As String
Dim myAxisTitle As String

Private Sub cmdShowChart_Click()

Call GetValues 'Gets values, ranges, etc for populating th
chart

Set myChtObj = ActiveSheet.ChartObjects.Add _
(Left:=1000, Width:=528, Top:=100, Height:=282)
Set myNewSeries1 = myChtObj.Chart.SeriesCollection.NewSeries
With myNewSeries1
.Name = myName1
.Values = myYValues1
.XValues = myXValues
.Border.ColorIndex = 11
.Border.Weight = xlThin
.Border.LineStyle = xlContinuous
.MarkerBackgroundColorIndex = 11 ~Get a "Unabl
to set the MarkerBackgroundColorIndex property of the Series class
error
'.MarkerBackgroundColor = 11 ~Trie
this to see if it made a difference - no luck
.MarkerForegroundColorIndex = 11 ~Sam
type of error
.MarkerStyle = xlMarkerStyleDiamond ~Sam
type of error
.MarkerSize = 5
.Smooth = False
~Same type of error
.Shadow = False
.ApplyDataLabels xlDataLabelsShowValue
End With
With myChtObj.Chart
.ChartType = xlLineMarkers
.HasTitle = True
.ChartTitle.Characters.Text = myChtTitle
.HasLegend = False
With .Axes(xlValue, xlPrimary)
.HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text
myAxisTitle ~Object doesn't support this property or method
End With
With .Axes(xlCategory, xlPrimary)
.HasTitle = False
With .TickLabels
.Alignment = xlCenter
.Offset = 100
.ReadingOrder = xlContext
.Orientation = 45
End With
End With
With .PlotArea
.Left = 1
.Top = 24
.Width = 354
.Height = 186
End With
End With
End If

' Save chart as GIF
Fname = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
~Type Mismatch
myChtObj.Chart.Export Filename:=Fname, FilterName:="GIF"

' Load Image to Form
Image1.Picture = LoadPicture(Fname)



I would appreciate any hel
 
D

David Welch

Hi,

You should set the chart type to xlLine before setting the markers. The
default chart type is (I think) a column chart, which doesn't have markers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top