|
ChartDirector and PowerPoint |
Posted by Daniel on Jun-12-2013 01:35 |
|
Hello Peter,
I would like to know if is it possible to export a certain chart on a PowerPoint slide directly
(in run time) using a code such as below :
Dim c As XYChart
Set c = cd.XYChart(600, 400)
........................................
c.makeChart myPath
Thank you in advance.
Daniel |
Re: ChartDirector and PowerPoint |
Posted by Peter Kwan on Jun-12-2013 02:45 |
|
Hi Daniel,
After creating the chart as an image file using "c.makeChart myPath", you can always create a PowerPoint slide and import the image into the slide. You may refer to Microsoft documentation on how to create PowerPoint slides and import images programatically.
http://msdn.microsoft.com/en-us/library/aa213582.aspx
In brief, the code should be something like:
Set oApp = CreateObject("PowerPoint.Application")
Set oPres = oApp.Presentations.Add(msoFalse)
Set oSlide = oPres.Slides.Add(1, 12)
Call oSlide.Shapes.AddPicture("c:\\path\\to\\mychart.png", False, True, 100, 100, 500, 350)
Call oPres.SaveAs("c:\\aaa.ppt")
Call oApp.Quit()
Hope this can help.
Regards
Peter Kwan |
Re: ChartDirector and PowerPoint |
Posted by Daniel on Jun-12-2013 14:32 |
|
Hi Peter,
Of course, we can insert a CD chart on a PowerPoint slide programatically but the way we have to do this I feel it is not the best practice ... Looking at the VBA code line suggested by you
oSlide.Shapes.AddPicture("c:\\path\\to\\mychart.png", False, True, 100, 100, 500, 350)
we see that we should have the CD chart saved somewhere already so that to be able to transfer it a bit later on the slide ...Let's say we save it on the desktop or in a certain folder, we should delete it later, after it is inserted on the slide because as long as our output is a ppt file the chart as picture will be not longer useful...
Do you fell that this process is not very convenient/comfortable ? ... So, create a chart picture - save it temporary somewhere - insert the picture in the slide - delete the original chart picture !
Taking into account all these steps, I wonder if there is other method to transfer the chart on the slide without save it previously. Maybe something via Clipboard using copy-paste method, I dont know...I think you should consider in the future some new functions/methods on this topic because often an user needs to insert its charts in PowerPoint presentations.
Regards,
Daniel |
Re: ChartDirector and PowerPoint |
Posted by Peter Kwan on Jun-13-2013 02:12 |
|
Hi Daniel,
You can in face copy the chart to the clipboard without creating a file in memory. Basically, ChartDirector can create the image in memory, and the Windows API and VB6 allows the image in memory to be copied to the clipboard. See:
http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1135015330#N1356371469
I have not tried myself, but PowerPoint should allow an image to be paste from the clipboard programmatically onto a slide.
Hope this can help.
Regards
Peter Kwan |
|