Perl OLE Excel - edit width/height Comment window

Discussion in 'Perl Misc' started by Slickuser, May 8, 2008.

  1. Slickuser

    Slickuser Guest

    I have achieved adding comments but I can't change the width and
    height of the comment box. Any help?

    This is the VBA macro code:
    Range("C23").Comment.Text Text:= _
    "Slickuser:" & Chr(10) & "Helllo " & Chr(10) & ""
    & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "wowow this
    is awesome!!!!!!!!!!!! " & Chr(10) & "what!!"
    Selection.ShapeRange.ScaleWidth 1.76, msoFalse,
    msoScaleFromTopLeft
    Selection.ShapeRange.ScaleHeight 0.54, msoFalse,
    msoScaleFromTopLeft
    Range("C23").Comment.Shape.Select True
    ActiveWindow.SmallScroll Down:=6
    Range("F19").Select


    Perl OLE Browser info:

    Comment: Property Shape As Shape readonly
    ShapeRange: Sub ScaleHeight(Factor As VT_R4, RelativeToOriginalSize As
    MsoTriState, [Scale])


    Here is the Perl code:

    $Range_Enter = $Worksheet->Range("C23");

    $Range_Enter->{AddComment};
    $Range_Enter->{Comment}->{Visible} = 0;
    my $string = "".$Range_Enter->{Comment}->{Author}.":
    \nHelllo \n\n\n\n\nwowow this is awesome!!!!!!!!!!!!
    \nwhat!!" ;
    $Range_Enter->{Comment}->Text($string);

    //not sure how to translate this with Selection
    #$Range_Enter>{ShapeRange}->ScaleWidth("1.76, msoFalse,
    msoScaleFromTopLeft");
    #$Range_Enter->{ShapeRange}->ScaleHeight("0.54, msoFalse,
    msoScaleFromTopLeft");
     
    Slickuser, May 8, 2008
    #1
    1. Advertising

  2. Slickuser wrote:
    > I have achieved adding comments but I can't change the width and
    > height of the comment box. Any help?
    >
    > This is the VBA macro code:
    > Range("C23").Comment.Text Text:= _
    > "Slickuser:" & Chr(10) & "Helllo " & Chr(10) & ""
    > & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "wowow this
    > is awesome!!!!!!!!!!!! " & Chr(10) & "what!!"
    > Selection.ShapeRange.ScaleWidth 1.76, msoFalse,
    > msoScaleFromTopLeft
    > Selection.ShapeRange.ScaleHeight 0.54, msoFalse,
    > msoScaleFromTopLeft
    > Range("C23").Comment.Shape.Select True
    > ActiveWindow.SmallScroll Down:=6
    > Range("F19").Select
    >
    >
    > Perl OLE Browser info:
    >
    > Comment: Property Shape As Shape readonly
    > ShapeRange: Sub ScaleHeight(Factor As VT_R4, RelativeToOriginalSize As
    > MsoTriState, [Scale])
    >
    >
    > Here is the Perl code:
    >
    > $Range_Enter = $Worksheet->Range("C23");
    >
    > $Range_Enter->{AddComment};

    $my $comment = $Range_Enter->{AddComment};

    > $Range_Enter->{Comment}->{Visible} = 0;

    $comment->{Visible} = 1;

    > my $string = "".$Range_Enter->{Comment}->{Author}.":
    > \nHelllo \n\n\n\n\nwowow this is awesome!!!!!!!!!!!!
    > \nwhat!!" ;


    my $string = $comment->{Author} . ":.........";

    > $Range_Enter->{Comment}->Text($string);

    $comment->Text($string);

    >
    > //not sure how to translate this with Selection
    > #$Range_Enter>{ShapeRange}->ScaleWidth("1.76, msoFalse, msoScaleFromTopLeft");
    > #$Range_Enter->{ShapeRange}->ScaleHeight("0.54, msoFalse, msoScaleFromTopLeft");


    use constant msoFalse => 0; # or import the entire Office typelib
    use constant msoScaleFromTopLeft => 0;

    my $shape = $comment->{Shape}; # now you have your shape object
    $shape->ScaleWidth( 1.76, msoFalse, msoScaleFromTopLeft );
    $shape->ScaleHeight(0.54, msoFalse, msoScaleFromTopLeft );


    In your excel macro, the ScaleWidth and ScaleHeight functions were
    called on the current selection, you need to make get that "selection"
    in perl before you can operate on it.

    --
    -brian
     
    Brian Helterline, May 8, 2008
    #2
    1. Advertising

  3. Slickuser

    Slickuser Guest

    Thanks but my original question is still asking how to use selection
    method with the ScaleWidth function call.

    On May 8, 1:16 pm, Brian Helterline <> wrote:
    > Slickuser wrote:
    > > I have achieved adding comments but I can't change the width and
    > > height of the comment box. Any help?

    >
    > > This is the VBA macro code:
    > > Range("C23").Comment.Text Text:= _
    > > "Slickuser:" & Chr(10) & "Helllo " & Chr(10) & ""
    > > & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "wowow this
    > > is awesome!!!!!!!!!!!! " & Chr(10) & "what!!"
    > > Selection.ShapeRange.ScaleWidth 1.76, msoFalse,
    > > msoScaleFromTopLeft
    > > Selection.ShapeRange.ScaleHeight 0.54, msoFalse,
    > > msoScaleFromTopLeft
    > > Range("C23").Comment.Shape.Select True
    > > ActiveWindow.SmallScroll Down:=6
    > > Range("F19").Select

    >
    > > Perl OLE Browser info:

    >
    > > Comment: Property Shape As Shape readonly
    > > ShapeRange: Sub ScaleHeight(Factor As VT_R4, RelativeToOriginalSize As
    > > MsoTriState, [Scale])

    >
    > > Here is the Perl code:

    >
    > > $Range_Enter = $Worksheet->Range("C23");

    >
    > > $Range_Enter->{AddComment};

    >
    > $my $comment = $Range_Enter->{AddComment};
    >
    > > $Range_Enter->{Comment}->{Visible} = 0;

    >
    > $comment->{Visible} = 1;
    >
    > > my $string = "".$Range_Enter->{Comment}->{Author}.":
    > > \nHelllo \n\n\n\n\nwowow this is awesome!!!!!!!!!!!!
    > > \nwhat!!" ;

    >
    > my $string = $comment->{Author} . ":.........";
    >
    > > $Range_Enter->{Comment}->Text($string);

    >
    > $comment->Text($string);
    >
    >
    >
    > > //not sure how to translate this with Selection
    > > #$Range_Enter>{ShapeRange}->ScaleWidth("1.76, msoFalse, msoScaleFromTopLeft");
    > > #$Range_Enter->{ShapeRange}->ScaleHeight("0.54, msoFalse, msoScaleFromTopLeft");

    >
    > use constant msoFalse => 0; # or import the entire Office typelib
    > use constant msoScaleFromTopLeft => 0;
    >
    > my $shape = $comment->{Shape}; # now you have your shape object
    > $shape->ScaleWidth( 1.76, msoFalse, msoScaleFromTopLeft );
    > $shape->ScaleHeight(0.54, msoFalse, msoScaleFromTopLeft );
    >
    > In your excel macro, the ScaleWidth and ScaleHeight functions were
    > called on the current selection, you need to make get that "selection"
    > in perl before you can operate on it.
    >
    > --
    > -brian
     
    Slickuser, May 9, 2008
    #3
  4. Slickuser

    Slickuser Guest

    Selection was confusing.

    But here is the correct code:

    $Range_Enter = $Worksheet->Range("C23");

    my $comment = $Range_Enter->{AddComment};
    $comment->{Visible} = 1;
    my $string = $comment->{Author} . ":\nHelllo \n\n\n\n
    \nwowow this is awesome!!!!!!!!!!!! \nwhat!!";
    $comment->Text($string);

    my $shape = $comment->{Shape};
    $shape->Select;
    $shape->ScaleWidth( 1.75, msoFalse, msoScaleFromTopLeft);
    $shape->ScaleHeight(2, msoFalse, msoScaleFromTopLeft);

    Thanks for the help Brian!
    On May 9, 3:06 pm, Slickuser <> wrote:
    > Thanks but my original question is still asking how to use selection
    > method with the ScaleWidth function call.
    >
    > On May 8, 1:16 pm, Brian Helterline <> wrote:
    >
    > > Slickuser wrote:
    > > > I have achieved adding comments but I can't change the width and
    > > > height of the comment box. Any help?

    >
    > > > This is the VBA macro code:
    > > > Range("C23").Comment.Text Text:= _
    > > > "Slickuser:" & Chr(10) & "Helllo " & Chr(10) & ""
    > > > & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "wowow this
    > > > is awesome!!!!!!!!!!!! " & Chr(10) & "what!!"
    > > > Selection.ShapeRange.ScaleWidth 1.76, msoFalse,
    > > > msoScaleFromTopLeft
    > > > Selection.ShapeRange.ScaleHeight 0.54, msoFalse,
    > > > msoScaleFromTopLeft
    > > > Range("C23").Comment.Shape.Select True
    > > > ActiveWindow.SmallScroll Down:=6
    > > > Range("F19").Select

    >
    > > > Perl OLE Browser info:

    >
    > > > Comment: Property Shape As Shape readonly
    > > > ShapeRange: Sub ScaleHeight(Factor As VT_R4, RelativeToOriginalSize As
    > > > MsoTriState, [Scale])

    >
    > > > Here is the Perl code:

    >
    > > > $Range_Enter = $Worksheet->Range("C23");

    >
    > > > $Range_Enter->{AddComment};

    >
    > > $my $comment = $Range_Enter->{AddComment};

    >
    > > > $Range_Enter->{Comment}->{Visible} = 0;

    >
    > > $comment->{Visible} = 1;

    >
    > > > my $string = "".$Range_Enter->{Comment}->{Author}.":
    > > > \nHelllo \n\n\n\n\nwowow this is awesome!!!!!!!!!!!!
    > > > \nwhat!!" ;

    >
    > > my $string = $comment->{Author} . ":.........";

    >
    > > > $Range_Enter->{Comment}->Text($string);

    >
    > > $comment->Text($string);

    >
    > > > //not sure how to translate this with Selection
    > > > #$Range_Enter>{ShapeRange}->ScaleWidth("1.76, msoFalse, msoScaleFromTopLeft");
    > > > #$Range_Enter->{ShapeRange}->ScaleHeight("0.54, msoFalse, msoScaleFromTopLeft");

    >
    > > use constant msoFalse => 0; # or import the entire Office typelib
    > > use constant msoScaleFromTopLeft => 0;

    >
    > > my $shape = $comment->{Shape}; # now you have your shape object
    > > $shape->ScaleWidth( 1.76, msoFalse, msoScaleFromTopLeft );
    > > $shape->ScaleHeight(0.54, msoFalse, msoScaleFromTopLeft );

    >
    > > In your excel macro, the ScaleWidth and ScaleHeight functions were
    > > called on the current selection, you need to make get that "selection"
    > > in perl before you can operate on it.

    >
    > > --
    > > -brian
     
    Slickuser, May 9, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lois
    Replies:
    1
    Views:
    3,245
    Ryan Stewart
    Dec 27, 2004
  2. cera
    Replies:
    1
    Views:
    1,274
    Neredbojias
    Aug 18, 2007
  3. Bernd Meier
    Replies:
    6
    Views:
    518
    GTalbot
    Jan 14, 2008
  4. K Schleyer

    Can I programmatically change width/height of column in edit mode

    K Schleyer, Jan 16, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    159
    K Schleyer
    Jan 16, 2004
  5. Rodolfo Hinojosa~
    Replies:
    0
    Views:
    197
    Rodolfo Hinojosa~
    Feb 22, 2005
Loading...

Share This Page