in reply to Word tables, OLE, perl, and me.

Update: Just read the whole post.. And I had this problem as well. ( See bottom: )

TABLE TO EXCEL I had this problem a few months ago and the following worked fine for me. The only real differences from the previous suggestions is I used the 'Range' property not the 'Range' method.
# This was inside a wrapper hence the Excel object was stored as b +elow my $book = $self->{Excel}->Workbooks->Add; # I also had previously stored all the tables in the object my $table = $self->{Tables}->[$i]; # Copy the table range $table->{Range}->Copy(); # Add a new worksheet my $sheet = $Book->Worksheets->Add; $sheet->Paste; $self->{Excel}->{DisplayAlerts} = False; $sheet->Delete(); # Close the excel book $book->Close( { SaveChanges => False } ); # Empty clip board Win32::Clipboard->Empty();

Without meaning to sound a pesamist this will probably be the first of many prolems. I've been working on this for last few months and other issues you'll probably face will be:
- Merged cells: 'Only an issue if you actually want to extract the dat +a when saved as txt tables (which I was)' - Wraped cells in word: Wrapped cells will copy to excel to the number + of rows their text covers.
E.g.:
|----------------| | A Heading | | that is wraped | |----------------| becomes |----------------| | A Heading | |----------------| | that is wraped | |----------------| in excel

I've solved both the above and a few others but the solutions arn't really worth going to here.
- John

Update: I think you can actually used both {Range} and Range to represent the property but the code I listed definately works for me. (Sorry it isn't self containing but it's quite hard to put word table object in __DATA__ ;) (I'll probably be proved wrong though) )



TABLE TITLE: The way I did this was to have a regular expresison mathcing the title paragraph and store the start location of each title and table and then merging the two arrays based on location ( My titles weren't always neatly above the table occassionally missing ).
For table start $table->{Range}{Start} For Paragraph start $paragraph->{Range}{Start}