D
deko
As far as I can tell, this *should* embed my chart in the Active worksheet:
xlapp.Workbooks(strXlsFile).ActiveChart.Location Where:= _
xlLocationAsObject, Name:=strSheetName
(where strSheetName is the name of the target worksheet)
But when I put this code in a loop, the chart is created in it's *own
sheet*:
xlapp.Workbooks(strXlsFile).Charts.Add.Name = strSheetName
xlapp.Workbooks(strXlsFile).ActiveChart.SetSourceData Source:= _
xlapp.Workbooks(strXlsFile).Worksheets(j + 1).Range("A1:C" & _
xlapp.Workbooks(strXlsFile).Worksheets(j + 1).Range("C1").End(xlDown).Row),
PlotBy:=xlColumns
xlapp.Workbooks(strXlsFile).ActiveChart.Axes(xlCategory, xlPrimary).HasTitle
= False
xlapp.Workbooks(strXlsFile).ActiveChart.Axes(xlValue, xlPrimary).HasTitle =
False
xlapp.Workbooks(strXlsFile).ActiveChart.HasLegend = False
xlapp.Workbooks(strXlsFile).ActiveChart.HasTitle = False
Am I missing something obvious, or do I need to do something different when
using automation?
Thanks in advance.
xlapp.Workbooks(strXlsFile).ActiveChart.Location Where:= _
xlLocationAsObject, Name:=strSheetName
(where strSheetName is the name of the target worksheet)
But when I put this code in a loop, the chart is created in it's *own
sheet*:
xlapp.Workbooks(strXlsFile).Charts.Add.Name = strSheetName
xlapp.Workbooks(strXlsFile).ActiveChart.SetSourceData Source:= _
xlapp.Workbooks(strXlsFile).Worksheets(j + 1).Range("A1:C" & _
xlapp.Workbooks(strXlsFile).Worksheets(j + 1).Range("C1").End(xlDown).Row),
PlotBy:=xlColumns
xlapp.Workbooks(strXlsFile).ActiveChart.Axes(xlCategory, xlPrimary).HasTitle
= False
xlapp.Workbooks(strXlsFile).ActiveChart.Axes(xlValue, xlPrimary).HasTitle =
False
xlapp.Workbooks(strXlsFile).ActiveChart.HasLegend = False
xlapp.Workbooks(strXlsFile).ActiveChart.HasTitle = False
Am I missing something obvious, or do I need to do something different when
using automation?
Thanks in advance.