in reply to Can I save my document to html page?

Just to make it easy on the eyes:
use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; # imports word constants like wdFormtaDosTxtLineBreaks my $Word = Win32::OLE->new( 'Word.Application', 'Quit' ); $Word->{'Visible'} = 1; # second argument tells OLE what to do if everything goes tits up my $Document = $Word->Documents->Open( "f:\\aa.doc" ); $Document->SaveAs( { FileName => 'bb.htm', FileFormat => wdFormatHTML +} ); # NOTE!!! wdFormatDOSTextLineBreaks, wdFormatHTML, etc., are #constants, not strings, so don't quote them! $Document->Close(); $Word->Quit(); exit( 0 );


elbow

update nevermind - broquaint did it too.....

Replies are listed 'Best First'.
Re: Re: Can I save my document to html page?
by Aragorn (Curate) on Jan 21, 2003 at 11:07 UTC
    Looking at the error message, it seems to me that the constant wdFormatHTML is not defined, hence the complaint about the bareword. I'm not a Win32 programmer, but maybe there's a spelling error somewhere or something like that.

    Arjen

    Updated:forgot a word.

      You could try something like this to list all the wd* constants which are imported (untested):

      C:\perl -M'Win32::OLE::Const "Microsoft Word"'\ -e 'print join("\n", grep { /^wd/ } keys %main::;

      Arjen