I have a macro that takes my excel tables, opens up powerpoint, creates a new chart, and pulls in the data from the excel tables. I however receive a "Type Mismatch" error when I try to set the source data. Can anyone point me in the right direction? Here is some of the code:
Code:
pptPrs.Slides.AddSlide pptPrs.Slides.count + 1, pptPrs.SlideMaster.CustomLayouts(slType)
pptPrs.Slides(pptPrs.Slides.count).Select
Set pptChrtObj = pptPrs.Slides(pptPrs.Slides.count).Shapes.AddChart.Chart
Set pptChrtData = pptChrtObj.ChartData
Set pptChrtWB = pptChrtData.Workbook
Set pptChrtWS = pptChrtWB.Worksheets(1)
With pptChrtObj
.ChartType = chrtType
.ChartArea.Font.Name = "Arial"
.ChartArea.Font.Size = fontSz#
.ChartArea.Font.Name = False
.ChartArea.AutoScaleFont = False
.Axes(xlCategory).HasMajorGridlines = False
.Axes(xlValue).HasMajorGridlines = False
.Axes(xlValue).MaximumScale = 100
Do Until .SeriesCollection.count = 0
.SeriesCollection(1).Delete
Loop
With .ChartData.Workbook.Sheets(1)
.Cells.Clear
' Lengthy code that inserts certain data from initial excel workbook into the chart dataset
End With
For a = 2 To Range("A2").End(xlToRight).Column
With .SeriesCollection.NewSeries
.Name = Cells(1, a)
.Values = Range(Cells(2, a), Cells(Range("A2").End(xlDown).Row, a)).Select
End With
Next
.SetSourceData Source:=Range(Cells(1, 1), Cells(Range("A2").End(xlDown).Row, Range("B2").End(xlToRight).Column))