my @headers = ("Header ONE", "Header TWO", "Header THREE" , "Header FOUR"); my $MyRange = $Word->ActiveDocument->Content; # Add a table at the end of the content. $Word->ActiveDocument->Tables->Add({ Range => $MyRange, NumRows => 1, NumColumns => ($#headers+1), }); #put headers In foreach my $str (0..$#headers){ my $Cell = $Word->ActiveDocument->Tables(1)->Cell(1,($str+1))->Select; $Word->Selection->TypeText ({ Text => $headers[$str]}); } #Do some simple styling with the header row. my $Row = $Word->ActiveDocument->Tables(1)->Rows(1); $Row->Shading->{BackgroundPatternColor} = wdColorGray40; my @borders = (wdBorderBottom, wdBorderTop, wdBorderLeft, wdBorderRight); foreach my $bord (@borders){ with (my $Borders = $Row->Borders->Item($bord), LineStyle=>wdLineStyleSingle, LineWidth=>wdLineWidth300pt);} my $table = $Word->ActiveDocument->Tables(1); my $lastrow = $table->Rows->{Count}; # Put the data in, based on the number of header columns while ($lastrow < 15){ my $color; $table->Rows($lastrow)->Select(); $Word->Selection->InsertRowsBelow(1); $lastrow++; my $test = $lastrow%2; if (!$test){$color = wdColorWhite;}else{$color = wdColorGray40;} $Word->ActiveDocument->Tables(1)->Rows($lastrow)->Shading->{BackgroundPatternColor} = $color; foreach my $str (0..$#headers){#put Headers In my $Cell = $Word->ActiveDocument->Tables(1)->Cell($lastrow,($str+1))->Select; $Word->Selection->TypeText ({ Text => $Data [$str]}); } } with (my $Borders = $Row->Borders->Item(wdBorderBottom), LineStyle=>wdLineStyleSingle, LineWidth=>wdLineWidth300pt); my $Doc= $Word->{ActiveDocument}; $Doc->SaveAs('c:\perl\projects\testtable.doc');