I've written this code in Access to create a pivot chart in Excel. All the code listed is good except for the last line. The last line creates another instance of Excel. I can't figure out what the correct syntax is. I've tried, charts, worksheets, everything I can think of, and I can't figure it out.
Thanks in advance for your help!!
Thanks in advance for your help!!
Set xlApp = New Excel.Application
xlApp.Visible = True
Set wb1 = xlApp.Workbooks.Open("c:\chi\testpivot.xlsx")
wb1.Sheets.Add
wb1.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Qry1!R1C1:R2539C5", Version:=xlPivotTableVersion14).CreatePivotTable _
TableDestination:="Sheet1!R3C1", TableName:="PivotTable1", DefaultVersion _
:=xlPivotTableVersion14
wb1.Sheets(1).Select
wb1.Sheets(1).Cells(1, 1).Select
wb1.Sheets(1).Shapes.AddChart.Select
wb1.ActiveChart.ChartType = xlLineMarkers