Hi,
I am trying to make graph in excel from access. It works but graph appears to the wrong worksheet. It appears to the first sheet only. Is there anybody with similar problem?
Option Compare Database
Dim ApXL As Object
Dim xlWBk As Object
Dim xlWSh As Object
Dim strPath As String
Public Function Graafikud()
strPath = "C:\Mai Tokjuments\Mody\Aruanne02.xls"
Set ApXL = CreateObject("Excel.Application")
Set xlWBk = ApXL.Workbooks.Open(strPath)
SendTQ2ExcelSheet
ApXL.activeworkbook.Save
ApXL.activeworkbook.Close
ApXL.Quit
Set ApXL = Nothing
Set xlWBk = Nothing
Set xlWSh = Nothing
End Function
Public Sub SendTQ2ExcelSheet()
Set xlWSh = xlWBk.Worksheets("Tehniline")
ApXL.Visible = True
xlWSh.Activate
Range("A7:C14").Select
Charts.Add
ActiveChart.ChartType = xl3DPieExploded
ActiveChart.SetSourceData Source:=Sheets("Tehniline").Range("A7:C14"), PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "=Tehniline!R7C2:R14C2"
ActiveChart.Location Where:=xlLocationAsObject, Name:="Tehniline"
End Sub

I am trying to make graph in excel from access. It works but graph appears to the wrong worksheet. It appears to the first sheet only. Is there anybody with similar problem?
Option Compare Database
Dim ApXL As Object
Dim xlWBk As Object
Dim xlWSh As Object
Dim strPath As String
Public Function Graafikud()
strPath = "C:\Mai Tokjuments\Mody\Aruanne02.xls"
Set ApXL = CreateObject("Excel.Application")
Set xlWBk = ApXL.Workbooks.Open(strPath)
SendTQ2ExcelSheet
ApXL.activeworkbook.Save
ApXL.activeworkbook.Close
ApXL.Quit
Set ApXL = Nothing
Set xlWBk = Nothing
Set xlWSh = Nothing
End Function
Public Sub SendTQ2ExcelSheet()
Set xlWSh = xlWBk.Worksheets("Tehniline")
ApXL.Visible = True
xlWSh.Activate
Range("A7:C14").Select
Charts.Add
ActiveChart.ChartType = xl3DPieExploded
ActiveChart.SetSourceData Source:=Sheets("Tehniline").Range("A7:C14"), PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "=Tehniline!R7C2:R14C2"
ActiveChart.Location Where:=xlLocationAsObject, Name:="Tehniline"
End Sub