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");
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |