http://www.perlmonks.org?node_id=426546

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi

What is the perl equivalent of vba code line 1

0: dim str as string, Rng as range 1: str =Rng.style
I tried to use as follows
$str = $rng->{style}

But it returns an hash. im trying to get the style name of the range object

Pls help

Replies are listed 'Best First'.
Re: What is the perl equivalent of vba
by thinker (Parson) on Jan 31, 2005 at 10:50 UTC

    Hi there,

    Ok, I am assuming you have an object, $rng, of some type, and it has a style() method, you can call it by  $str = $rng->style();

    cheers

    thinker

      Really, the previous code is correct. The instance variable of the object is accessed in these form, or

      $str = $$rng{style};

      Bye.
Re: What is the perl equivalent of vba
by maa (Pilgrim) on Jan 31, 2005 at 15:35 UTC

    Since each Office Application has its own API you'll need to tell us if this is Word, Excel or PowerPoint... then we'll maybe be able to help.

Re: What is the perl equivalent of vba
by gube (Parson) on Feb 01, 2005 at 04:59 UTC

    Hi, try this with OLE module

    Please open the word document and use this

    use Win32::OLE; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Word'; $word=Win32::OLE->GetActiveObject('Word.Application'); $doc= $word->activedocument; foreach my $val (in $doc->styles){ push @styles,$val->{namelocal}; } $"="\n"; print "@styles";

    Regards,
    Gubendran.L