in reply to Set the sheet #2 for View Zoom to 75%

After a little playing around with this code example, and Excel 2003, it appears that some of the methods seem to operate only on the active worksheet that was last used, or on-top (The view at 75%) is one of them. This leads me to believe that Excel needs a more in-depth pointer to the sheet you want to use the methods on. I am not overly familiar with how to manipulate these as you seem to need, but I did read that the structure available to access the sheets and their properties can be found in the Visual Basic Help.

I did however include the code that I found from CPAN. Definitely, read the Win32::OLE documentation and use the Excel package example as it handles the closing of files even on abortion of the perl script. Otherwise, the excel file gets locked for editing. Wish I could do more :-(

Hints for Microsoft Office automation

Documentation

The object model for the Office applications is defined in the Visual Basic reference guides for the various applications. These are typically not installed by default during the standard installation. They can be added later by rerunning the setup program with the custom install option. Class, Method and Property names

The names have been changed between different versions of Office. For example Application was a method in Office 95 and is a property in Office97. Therefore it will not show up in the list of property names keys %$object when querying an Office 95 object.

The class names are not always identical to the method/property names producing the object. E.g. the Workbook method returns an object of type Workbook in Office 95 and _Workbook in Office 97.

And it goes on...

#!perl use Excel; my $file = "C:\\perl_proj\\book1.xls"; my $ex = Excel->new('Excel.Application', sub {$_[0]->Quit;}) or die "O +ops, cannot start Excel"; my $Book = $ex->Workbooks->Open($file); my $Sheet1 = $Book->Worksheets(1); $Book->Windows(1)->{Zoom} = 75; $Sheet1->Columns->Font->{Size} = 12; my $Sheet2 = $Book->Worksheets(2); $Sheet2->Columns->{NumberFormat} = "#,##0.00"; $Book = $ex->Workbooks->Close();
The Excel Module from the CPAN page Win32::OLE
package Excel; use Win32::OLE; sub new { my $s = {}; if ($s->{Ex} = Win32::OLE->new('Excel.Application')) { return bless $s, shift; } return undef; } sub DESTROY { my $s = shift; if (exists $s->{Ex}) { print "# closing connection\n"; $s->{Ex}->Quit; return undef; } } sub AUTOLOAD { my $s = shift; $AUTOLOAD =~ s/^.*:://; $s->{Ex}->$AUTOLOAD(@_); } 1;