in reply to Re: Create a chart in PPT
in thread Create a chart in PPT

I don't know VBA, I looked at that link and could not understand it:-(, If you can please say the command to create a chart and provide data to that chart. Thank you

Replies are listed 'Best First'.
Re^3: Create a chart in PPT
by marto (Cardinal) on Mar 21, 2013 at 09:12 UTC

    Oddly enough, nobody knows VBA from birth, you have to learn it, like most other things. The link I provided you with gives a short example of VBA to Perl/Win32::OLE conversion.

Re^3: Create a chart in PPT
by hdb (Monsignor) on Mar 21, 2013 at 10:10 UTC

    Let me help you to get started. But I am afraid if you want to program MS Office using Perl, you have to learn this...

    my $chart = $Slide->Shapes->AddOLEObject( 50, 50, 500, 500, "MSGraph.C +hart" ); my $graph = $chart->OLEFormat->Object; my $datasheet = $graph->Application->DataSheet; explore( $datasheet ); $datasheet->Cells(1,2)->{'Value'} = "Col1"; $datasheet->Cells(1,3)->{'Value'} = "Col2"; $datasheet->Cells(1,4)->{'Value'} = "Col3"; $datasheet->Cells(1,5)->{'Value'} = "Col4"; $datasheet->Cells(2,1)->{'Value'} = "Row1"; $datasheet->Cells(3,1)->{'Value'} = "Row2"; $datasheet->Cells(4,1)->{'Value'} = "Row3"; $datasheet->Cells(5,1)->{'Value'} = "Row4"; for( my $row=2; $row<=5; $row++ ) { for( my $col=2; $col<=5; $col++ ) { $datasheet->Cells($row,$col)->{'Value'} = rand(); } } $datasheet->Application->Update;

    Right now I have not time to exhaustively test this so you need to play with it as described in my earlier post.

      If you define a sub like this

      sub explore { my $obj = shift; print "Exploring $obj (".ref($obj).")\n"; if( ref($obj) =~ /Win32::OLE/ ) { for my $key (sort keys %{$obj}) { print "\t$key => ".$obj->$key."\n"; } } }

      and then apply it to one of the VB objects like this

      explore( $datasheet );

      you get all the possible fields you can work with:

      Application => Win32::OLE=HASH(0x385ca80) Cells => Win32::OLE=HASH(0x3491660) Columns => Win32::OLE=HASH(0x3491678) Creator => 1297303378 Font => Win32::OLE=HASH(0x34915a0) Height => 0 Left => 4359 Parent => Win32::OLE=HASH(0x3491720) Range => Rows => Win32::OLE=HASH(0x3491708) Top => 4337 Width => 0
      .

      This way you can find your ways through the VB object djungle (d is silent).

      Thanks a lot for your code. Can you give me a way to remove that small box giving the details "Col1", "Col2" etc, Since I use only one column, the box dispalys as "3D Column-3" & "3-D Column 4". I Can't find a way to remove this. Even when I place null in that location using your own way, it still comes up like that, please suggest a way if you know This is how I put the null

      $datasheet->Cells(1,5)->{'Value'} = "";