Mjpaddy has asked for the wisdom of the Perl Monks concerning the following question:
I trying to copy data from one doc file and paste it at top of another doc file with separator like "xxxxxxxxxxxxxxxxxxxxx", I have two doc files.
first doc(copyfrom.doc) contain a small table while in another doc(copyto.doc) contain a paragraph.
So the logic is copy table from copyfrom.doc and paste at top with separator in copyto.doc
use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; use strict; my $File1 = "D:\\Copyfrom1.doc"; my $File2 = "D:\\copyfrom2.doc"; my $Word = new Win32::OLE 'Word.Application', 'Quit'; $Word->{'Visible'}=1; $Word->Documents->open( $File1) or die "Unable to open $File1", Win32::OLE->LastError(); $sep = "\n\n\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n\n\n"; my $text = $Word->ActiveDocument->Content->InsertAfter({Text => $sep}) +; $text = $Word->ActiveDocument->Content->Text; $Word->ActiveDocument->Close; $Word->Documents->open( $File2) or die "Unable to open $File2", Win32::OLE->LastError(); $Word->ActiveDocument->Content->InsertBefore({ Text => $text }); $Word->ActiveDocument->SaveAs('D:\\Merge.doc'); $Word->ActiveDocument->Close;
Please help me
Thanks in advanced
|
|---|