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.

In reply to Excel FitToPages bizarrity by esr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.