Thread
:
How to embed chart in active worksheet with VBA?
View Single Post
#
2
Posted to microsoft.public.excel.programming
Tushar Mehta
external usenet poster
Posts: 1,071
How to embed chart in active worksheet with VBA?
(a) What code does XL generate when you use its macro recorder?
(b) If you already have a worksheet named strSheetName, how do you
expect
xlapp.Workbooks(strXlsFile).Charts.Add.Name = strSheetName
to work?
--
Regards,
Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
In article ,
says...
As far as I can tell, this *should* embed my chart in the Active worksheet:
xlapp.Workbooks(strXlsFile).ActiveChart.Location Whe= _
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.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.Axes(xlCat egory, xlPrimary).HasTitle
= False
xlapp.Workbooks(strXlsFile).ActiveChart.Axes(xlVal ue, 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.
Reply With Quote
Tushar Mehta
View Public Profile
Find all posts by Tushar Mehta