I am creating a word doc which has both text and tables using win32::ole. I am creating the table using the below sample code. Problem is writing the text after the table. I am not able to move the selection to the end of the table. The text I want to write after the table, appears within the table based on the wrapping of the text in the table cell. Please suggest.

Below code works fine

use Win32::OLE; my ($t_row, $t_col) = (3,3); my $word = Win32::OLE->CreateObject("Word.Application"); $word->{Visible} = 1; my $doc = $word->Documents->Add('D:\new.dotx',0,0,-1); my $table = $doc->Tables->Add($word->Selection->Range,$t_row, $t_col); $table->Select(); $table->Cell(1,1)->Range->{Text} = "heading1"; $table->Cell(1,2)->Range->{Text} = "heading2"; $table->Cell(1,3)->Range->{Text} = "heading3"; $table->Cell(2,1)->Range->{Text} = "Data21"; $table->Cell(2,2)->Range->{Text} = "Data22"; $table->Cell(2,3)->Range->{Text} = "Data23"; $table->Cell(3,1)->Range->{Text} = "Data31"; $table->Cell(3,2)->Range->{Text} = "Data32"; $table->Cell(3,3)->Range->{Text} = "Data33"; $word->Selection->MoveDown(5,4); $doc->ActiveWindow->Selection -> TypeText("This line should be after t +he table");

Problem with the Below Code is that it prints the line within the table

use Win32::OLE; my ($t_row, $t_col) = (3,3); my $word = Win32::OLE->CreateObject("Word.Application"); $word->{Visible} = 1; my $doc = $word->Documents->Add('D:\new.dotx',0,0,-1); my $table = $doc->Tables->Add($word->Selection->Range,$t_row, $t_col); $table->Select(); $table->Cell(1,1)->Range->{Text} = "heading1"; $table->Cell(1,2)->Range->{Text} = "heading2"; $table->Cell(1,3)->Range->{Text} = "heading3"; $table->Cell(2,1)->Range->{Text} = "Data21"; $table->Cell(2,2)->Range->{Text} = "Data22"; $table->Cell(2,3)->Range->{Text} = "Data23"; $table->Cell(3,1)->Range->{Text} = "Data31aaaaaaaaaaaaaaaaaaaaaaaaaaaa +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +aaaaaaaaaaaaaaaaaaaaaaaaa"; $table->Cell(3,2)->Range->{Text} = "Data32"; $table->Cell(3,3)->Range->{Text} = "Data33"; $word->Selection->MoveDown(5,4); $doc->ActiveWindow->Selection -> TypeText("This line should be after t +he table");

In reply to Writing text after creating a table in MS Word using win32::ole by Adithyakiran.k

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.