BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Powerpoint: Losing Chart Data

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Paul Brinson
Guest





PostPosted: Wed Dec 15, 2004 3:27 pm    Post subject: Powerpoint: Losing Chart Data Reply with quote



Hey,

When I use delphi to create a chart in powerpoint and set up the data
that goes into the chart everything seems to look OK when I open the
generated powerpoint file. However, when I double click the chart in
powerpoint the chart's data ends up getting lost and I just get the
sample data for a chart. My formatting is also lost. The chart just
looks like it was just added to the slide. I assume that there is
some magical call that I am missing in my OLE code. I have attached
my sample code.

CREATE POWERPOINT:

m_PowerPoint := TPowerPointApplication.Create(NIL);
m_PowerPoint.Connect();

OPEN PRESENTATION:

m_Presentation := TPowerPointPresentation.Create(nil);
m_Presentation.ConnectTo(m_PowerPoint.Presentations.Open(Filename,
OleVariant(msoFalse), OleVariant(msoTrue), OleVariant(msoFalse)));

CREATE SLIDE: (a copy of a slide in the presentation that was opened)

m_Presentation.Slides.Item(1).Copy;
Slide.ConnectTo(m_Presentation.Slides.Item(m_Presentation.Slides.Count));

CREATE CHART AND SET DATA:

dataShape := Slide.Shapes.AddOLEObject(topX, topY, width, height,
'MSGraph.Chart', '', msoFalse, '', -1, '', msoFalse);

chartObj := dataShape.OLEFormat;

chart := IDispatch(chartObj.Object) as Graph_TLB.Chart;
chart.ChartType := xlBarClustered;
chart.HasDataTable := False;
chart.Legend.Position := xlLegendPositionBottom;
Axis(chart.Axes(xlCategory, xlPrimary)).HasMajorGridlines := False;
Axis(chart.Axes(xlCategory, xlPrimary)).HasMinorGridlines := False;
Axis(chart.Axes(xlValue, xlPrimary)).HasMajorGridlines := False;
Axis(chart.Axes(xlValue, xlPrimary)).HasMinorGridlines := False;

chartData := chart.Application.DataSheet;

chartData.Rows.ClearContents();
chartData.Columns.ClearContents();

chartData.Cells.Item[1, 2] := 'Series 1';
chartData.Cells.Item[1, 3] := 'Series 2';
chartData.Cells.Item[1, 4] := 'Series 3';
chartData.Cells.Item[2, 1] := 'Target';
chartData.Cells.Item[2, 2] := '56';
chartData.Cells.Item[2, 3] := '65';
chartData.Cells.Item[2, 4] := '76';
chartData.Cells.Item[3, 1] := 'Overall';
chartData.Cells.Item[3, 2] := '67';
chartData.Cells.Item[3, 3] := '76';
chartData.Cells.Item[3, 4] := '75';


I thought that running the dataShape.OLEFormat.DoVerb(1) to execute
the edit command on the OLE object would work, but that throws an
exception complaining about the presentation not being in slide view.
Unfortunately I don't appear to have a window in the powerpoint
application object to change the view type for. Was the whole
DoVerb() thing a wild goose chase?

Thanks!

~Paul
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.