Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Excel FitToPages bizarrity

by esr (Scribe)
on Aug 25, 2005 at 21:01 UTC ( #486722=perlquestion: print w/ replies, xml ) Need Help??
esr has asked for the wisdom of the Perl Monks concerning the following question:

I have a Perl program which writes some data into an Excel spreadsheet and does some formatting. I had some code in it to scale the spreadsheet using the PageSetup "adjust to percentage" which I needed to modify to use the "fit to pages" function instead. The VBA macro which I generated to see what code was needed indicated that I needed to set the "Zoom" property to "False". The original Perl code I tried was something like:
$sheet->PageSetup->{Zoom}='False';
which gave me an Exception error and didn't work. So I tried setting the value to zero. Same error. Setting the zoom value to a numeric value worked correctly so I knew the rest of the syntax was correct.

The frequently referred to "Using Win32::OLE and Excel - Tips and Tricks" document posted here indicated that the code needed to look like this:

my $vtfalse = Variant(VT_BOOL,0); $sheet->PageSetup->{Zoom}=$vtfalse;
I find this really bizarre. What is the difference between setting the value to zero or "false" and setting it using the variant value? I realize this is only partially a Perl question as it seems the apparent absurity is in the way Microsoft has "designed" the Office object package but I would appreciate any help anyone might be able to offer in understanding this.

Comment on Excel FitToPages bizarrity
Select or Download Code
Re: Excel FitToPages bizarrity
by InfiniteSilence (Curate) on Aug 25, 2005 at 21:20 UTC
    If you have Excel open and open the Visual Basic Editor (macro, edit) try hitting F2 for the object browser window. Type in "Zoom" and Then click on the "Page Setup" Class line...the one with the "Zoom" member. Now look below that pane. Do you notice that the property is a Variant?

    Celebrate Intellectual Diversity

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://486722]
Approved by InfiniteSilence
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2014-07-26 14:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (178 votes), past polls