in reply to Converting HTML to DOC

If you have Word installed, you can utilize Win32::OLE to make Word convert it for you.
use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; use File::Spec; my ($input_html,$output_doc) = @ARGV; my $word = Win32::OLE->CreateObject('Word.Application'); $word->{'Visible'} = 0; my $file = $word->Documents->Open({ FileName => File::Spec->rel2abs($input_html), Format => wdOpenFormatWebPages, ConfirmConversions => 0, AddToRecentFiles => 0, Revert => 0, ReadOnly => 1, OpenAndRepair => 0, }) or die dump $word; # Save As $word->ActiveDocument->SaveAs({ FileName => File::Spec->rel2abs($output_doc), FileFormat => wdFormatDocument, }); # Quit/Close $file->Close({SaveChanges => wdDoNotSaveChanges}); $word->Quit( {SaveChanges => wdDoNotSaveChanges});
Of course Word's sense of HTML is somewhat limited, but mostly that works quite well.

-- Roman

Replies are listed 'Best First'.
Re^2: Converting HTML to DOC
by gokuraku (Monk) on Apr 12, 2010 at 20:12 UTC
    Roman, this is great! It's what I was looking for, since my experience with most of the tools I found with Google was lacking and I wanted a nice scriptable option that I could feed files to from a PowerShell script.
    Thanks alot!