View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
deko[_2_] deko[_2_] is offline
external usenet poster
 
Posts: 53
Default How to embed chart in active worksheet with VBA?

I've been experimenting with the macro recorder and that is a big help, to
be sure.
I just tried this again, and this time no chart appears in the workbook.

xlapp.Workbooks(strXlsFile).Charts.Add
xlapp.Workbooks(strXlsFile).ActiveChart.ChartType = xlColumnClustered
xlapp.Workbooks(strXlsFile).ActiveChart.SetSourceD ata 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.Location Whe=xlLocationAsObject,
Name:=strSheetName

As far as I can tell, this is correct code. Please correct me if I'm wrong.