in reply to Re: Re: Problem with Excel and Win32::OLE
in thread Problem with Excel and Win32::OLE

If that's what is recorded, 'ActiveWindow' ne 'Worksheet' (your code uses Worksheet.Gridlines). You need to translate each object in VBA into the appropriate object in Perl. To help with the translation, either use the Object Browser in Excel, the OLE-Browser packaged with ActiveState's Perl, or search for Object Model in Excel's VBA help file.

Looking in the OLE-Browser for ActiveWindow, I see it is a property of the Application object. My application object is $excel in the following:

use strict; use warnings; use Win32::OLE; my $excel = Win32::OLE->CreateObject('Excel.Application', 'quit'); $excel->{Visible} = 1; $excel->Workbooks->Add(); $excel->ActiveWindow->{DisplayGridlines} = 0; #gridlines disappear! print "press enter..."; <STDIN>;

Remember - if you are having problems, check the Object Model!

Replies are listed 'Best First'.
Re: Re: Re: Re: Problem with Excel and Win32::OLE
by Streen (Sexton) on May 07, 2004 at 13:24 UTC
    Thanks for the help,

    I managed to solve the problem:
    $newworksheet->Activate(); $Excel->ActiveWindow->{DisplayGridlines} = 'False';


    But now I have an other problem... I searched in the object browser, but I din't manage to solve the problem.
    In a chart I would like to set the font size to 8... I recorded the following macro and I tried to set them to 8 but the fonts still 8 and no error message comes up.
    The VB macro
    Selection.TickLabels.AutoScaleFont = False With Selection.TickLabels.Font .Name = "Arial" .FontStyle = "Standard" .Size = 8 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic .Background = xlAutomatic End With

    Because only the Size is needed I tried to convert it into the following perl code:
    $Excel->Selection->ThickLabels({AutoScaleFont => 0}); $Excel->Selection->ThickLabels({Font => {Size => 8}});

    No error message and no size of 8, can anybody help me?
    Thanks a lot
      Selection.TickLabels.AutoScaleFont = False $Excel->Selection->ThickLabels({AutoScaleFont => 0});

      The first line is from the VBA code, the second is perl. See the extra 'h'?

        D'oh,
        and I searched hours for a solution...

        But the code:
        $Chart -> Axes(xlCategory) -> Select; $Excel->Selection->TickLabels({Font => {Size => 8}});

        Still won't function, it should resize the Font of the xlCategory in a chart to 8, but it still remains at the default size of 10... I tried several versions, but still won't function...

        Thanks for help...