View Single Post
  #10   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?

this worked for me:

Did you run this from an Access 2000 module?

Sub ABCD()
Dim j As Long, strXlsFile As String
Dim strSheetName As String, xlapp As Application
strXlsFile = "Book3"
strSheetName = "Sheet2"
j = 1
Set xlapp = Application
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

End Sub


Anyway, when the reference pointed to the data, the above code worked

fine.

hmm. still not working for me... :(