http://qs1969.pair.com?node_id=795700

romandas has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to use Perl's Win32::OLE module (via Dave Roth's excellent book) to automate a couple tasks I need to repeatedly perform on some Word documents. However, the book (and most web examples) tends to use Excel for examples, so I am not sure how to copy and paste effectively with the Tables collection object.

Here is a snippet of my code:

my $originalDoc = $MSWord->Documents->Open('C:\Perl\testDocument.doc') +; my $newDoc = $MSWord->Documents->Add; my $selection = $MSWord->Selection(); # this may be spurious my $count = int( $originalDoc->Tables()->{Count} ); my $range = $originalDoc->Tables()->Range( { Start => $originalDoc->Ta +bles(1)->{Range}->{Start}, End => $originalDoc->Ta +bles($count)->{Range}->{End} } ); $range->Copy(); $newDoc->Range()->Paste();

I'm getting a rather strange 'not enough storage to complete this action' error. How can I properly copy a range of tables from $originalDoc to $newDoc?

The original code used Paragraphs, not Tables, so I assume some of the bugs are artifacts from that code (or more likely my non-understanding of that code).