cormanaz has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; my $word = Win32::OLE->new('Word.Application') or die "Failure - word. + \n"; my $outputdoc = $word->Documents->Add; my @inputdocs = qw( foo.doc bar.doc); foreach my $f (@inputdocs) { my $inputdoc = $word->Documents->Open({FileName => "c:\\$f"}); my $inputparagraphs = $inputdoc->Paragraphs; foreach my $par (@$inputparagraphs) { #how to add to end of $outputdoc? } $inputdoc->close; } $outputdoc->SaveAs({FileName => 'c:\\combined.doc'});
So I guess my question is, is there a way to take a paragraph from the source doc and push it (with original formatting) onto the end of the paragraphs of the destination doc? The VBA reference for Word shows that there is a Paragraphs.Add method, but it seems that just adds a paragraph without putting anything in it. Any pointers appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32 OLE Word combining docs
by pryrt (Abbot) on Aug 23, 2016 at 22:14 UTC | |
by cormanaz (Deacon) on Aug 24, 2016 at 00:00 UTC |