in reply to Is there a way to embed Word or other Office applications into my perl app?

Here is some sample code used to extract numbers from a range of cells in Excel. This should help with the general idea of how the Win32 Oblect Linking and Embedding module works.

use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 3; my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); # Open Excel file my $Book = $Excel->Workbooks->Open("C:\\Temp\\ExcelFile.xls"); # Select worksheet number 1 my $Sheet = $Book->Worksheets(1); # Get the contents my $array = $Sheet->Range("B5:AT5")->{'Value'}; $Book->Close; foreach my $ref_array (@$array) { foreach my $scalar (@$ref_array) { print "$scalar\t"; } print "\n"; }
  • Comment on Re: Is there a way to embed Word or other Office applications into my perl app?
  • Download Code