WOO HOO!!!

That did it. Thank you.

Gary

Update: Apologies for my outburst, but as you can tell cacharbe's response solved a problem that I had been very frustrated with. I couldn't seem to find the ppSaveAsHTML constant anywhere. There doesn't seem to be much around with regards to manipulating PowerPoint documents, so I thought I'd post the code that I eventually came up with. It runs as a CGI, and takes the file name as an argument. It converts Excel, Word or PowerPoint documents to HTML, and also converts PowerPoint slides to JPEG, since Netscape can't view the HTML that PowerPoint creates. A simple script can display these JPEGs. This code would be better if it determined file type from MIME, but that's for another day. Hope this helps someone someday.

use CGI; use Win32::OLE::Const 'Microsoft Word'; use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::Const 'Microsoft PowerPoint'; use strict; my $q = new CGI; my $file_name = $q->param('file'); if ( $file_name eq '' ) { $file_name = $ARGV[0]; } my $in_dir = "C:\\some_dir\\"; my $out_dir = "C:\\some_other_dir\\"; # die on errors... $Win32::OLE::Warn = 3; if ( $file_name =~ m/\.doc$/ ) { convert_word( $file_name, $in_dir, $out_dir ); } elsif ( $file_name =~ m/\.xls$/ ) { convert_excel( $file_name, $in_dir, $out_dir ); } elsif ( $file_name =~ m/\.ppt$/ ) { convert_powerpoint( $file_name, $in_dir, $out_dir ); } exit; ################## sub convert_word { ################## my ( $file_name, $in_dir, $out_dir ) = @_; # get already active Word application or open new or die my $word = ( Win32::OLE->GetActiveObject('Word.Application') || Win32::OLE->new('Word.Application', 'Quit') || print Win32::OLE->LastError ); my $wd_in_filename = $in_dir.$file_name; my $word_doc = $word->Documents->Open($wd_in_filename); my $wd_out_filename = $out_dir.$file_name.".htm"; $word_doc->SaveAs( { FileName => "$wd_out_filename", FileFormat => 8 } ); # File Format 8 = HTML $word_doc->Close(); $word->Quit(); } ################### sub convert_excel { ################### my ( $file_name, $in_dir, $out_dir ) = @_; # get already active Excel application or open new or die my $excel = ( Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit') || print Win32::OLE->LastError ); my $xl_in_filename = $in_dir.$file_name; my $excel_doc = $excel->Workbooks->Open($xl_in_filename) or die "O +pen Failed"; my $excel_sheet = $excel_doc->Worksheets(1); my $xl_out_filename = $out_dir.$file_name.".htm"; unlink $xl_out_filename if -f $xl_out_filename; $excel_sheet->SaveAs( { 'FileName' => $xl_out_filename, 'FileFormat' => xlHtml } ); $excel_doc->Close(); $excel->Quit(); } ######################## sub convert_powerpoint { ######################## my ( $file_name, $in_dir, $out_dir ) = @_; # get already active PowerPoint application or open new or die my $powerpoint = ( Win32::OLE->GetActiveObject('PowerPoint.Applica +tion') || Win32::OLE->new('PowerPoint.Application', 'Quit') || print Win32::OLE->LastError ); my $pp_in_filename = $in_dir.$file_name; $powerpoint->{Visible} = 1; $powerpoint->Activate(); my $powerpoint_doc = $powerpoint->Presentations->Open($pp_in_filen +ame); my $pp_out_html_filename = $out_dir.$file_name.".htm"; my $pp_out_jpg_filename = $out_dir."ns\\".$file_name; ## output J +PEG for Netscape users $powerpoint_doc->SaveAs( { FileName => "$pp_out_html_filename", FileFormat => ppSaveAsHTML } ); $powerpoint_doc->SaveAs( { FileName => "$pp_out_jpg_filename", FileFormat => ppSaveAsJPG } ); $powerpoint_doc->Close(); return; }

In reply to Re: Re: Win32::OLE Powerpoint HTML by bassplayer
in thread Win32::OLE Powerpoint HTML by bassplayer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.