Hello monks,

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


In reply to copy doc to doc into new doc file by Mjpaddy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.