Dear monks,
I use win32::Ole to generate several powerpoint slides with a ms graph within (one graph per slide).
i have no problem to create the graph, setup it and feed the datasheet from a database, but when there's more than one graph in the presentation and when i try to edit a graph in powerpoint, it is resetted ( as if a new graph was inserted with the menu 'Insert->Chart...' ).
It doesn't happen with a single graph on a single slide, the graph can be then correctly edited, the values and the setup i defined in my script are kept.
Here's the way i create a new presentation:
###########################################################
#
# sub create_ppt_presentation
#
# create and return a new blank presentation
#
# $title is title for the presentation
#
###########################################################
sub create_ppt_presentation
{
my ($title) = @_;
my ($PptApp, $Presentation, $Slide);
trace("create_ppt_presentation: getting powerpoint.application obj
+ect\n");
$PptApp = Win32::OLE-> GetActiveObject('PowerPoint.Application')
|| Win32::OLE-> new('PowerPoint.Application', 'Quit');
$PptApp-> {Visible} = IS_PPT_VISIBLE;
$Presentation = $PptApp-> Presentations->Add();
return ($PptApp, $Presentation);
}
Here's the way i use to create a slide and add a graph within, using the previously created presentation object:
$Slide = $Presentation-> Slides->Add({Index => $position, Layout => pp
+LayoutBlank});
$Slide->{Name} = "test";
$graph_shape = $Slide->Shapes->AddOleObject({
Left => 10,
Top => 40,
Height => 450,
Width => 650,
ClassName => "MSGraph.Chart",
Link => 0});
$graph = $graph_shape->OLEFormat->{Object}; # ms graph chart object
# i can now work with $graph
Here's how i get the datasheet:
$datasheet = $graph->Application->{DataSheet};
$datasheet->Cells->ClearContents();
# i can now feed the datasheet with some datas
# ...
# after the settings of the datasheet's cells, free graph and data
+sheet
undef $datasheet;
undef $graph;
After this, here's how i save the powerpoint presentation.
Note i dont't close presentation object, and quit the powerpoint application object at the end of the script. ( Maybe the issue is here ?? )
# $Presentaion is the powerpoint presentation object
$Presentation->SaveAs("c:/test.ppt");
If anyone has an idea about this mysterious reset, i'll be sooo glad to hear it :o)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.