More fiddling around with Word documents using the Win32::OLE module (and my, now more capable, Win32::OLE::Word::Writer).
The mission, which I chose to accept, is to extract our Coding Standard from the MoinMoin wiki (a few pages per language) and put into a proper document.
Why not keep it in the wiki? Well, a proper document is thought to be more authoritative. But keeping two sources in sync won't work. Don't Repeat Yourself, so a Word document is created from the wiki pages.
At first I thought about fetching the Wiki markup and parse it, so I tried the Inline::Python module to re-use the original Python parser source. But it seems Inline::Python doesn't work on Windows, so that didn't work out very well. Would have been extremely cool if it had worked.
The next idea was to transform the HTML since there is slightly more prior art when it comes to parsing that particular format. Ovid's HTML::TokeParser::Simple turned out to be very useful (nice work!).
The simple module which I asked about on PerlMonks is now capable of dealing with styles (both paragraph and character based), multi-level bullet lists and (soon) tables.
Generally, working with Office Automation is a jungle. Okay, the documentation is pretty good, but sometimes things don't work as advertised. One problem I bumped into was that it didn't work to turn off the do-you-want-to-save-your-document? dialog.
The documented way is to:
$oWord = Win32::OLE->new('Word.Application'), 'Quit') ); $oWord->{DisplayAlerts} = $rhConst->{wdAlertsNone};
$oWord = Win32::OLE->new('Word.Application');and in the DESTROY of the containing Win32::OLE::Word::Writer object first insist that the document is already saved, and then quit:
$self->oDocument->{Saved} = 1; $self->oWord->Quit();