I want to add a variable length of text to a number of merged horizontal cells in a spreadsheet so that when more than one
line of text is required the row height is automatically increased so that all the text can be seen.
I have read in a book about writing Excel macros in VBA that the Range Object has a WrapText property that when true should do what I want.
I have attempted this in the Perl code below but all I can see is the first line and the row height has not changed. The Excel button shows that TextWrap is set for the cell when I move the cursor into the cell.
Can any Monk explain how I can achieve what I want?
use OLE; use Win32::OLE::Const "Microsoft Excel"; use strict "vars"; my ($excel, $workbook, $sheet); #___ DEFINE EXCEL $excel = CreateObject OLE "Excel.Application"; #___ MAKE EXCEL VISIBLE $excel -> {Visible} = 1; #___ ADD NEW WORKBOOK $workbook = $excel -> Workbooks -> Add; $sheet = $workbook -> Worksheets("Sheet1"); $sheet -> Activate; $sheet -> Range("B2:J2") -> Merge; $sheet -> Range("B2:J2") -> {WrapText} = "True"; $sheet -> Range("B2:J2") -> {Value} = "The cat sat on the mat under th +e Christmas tree looking at the chocolate mouse that the little boy h +ad dropped on the floor near the raoring log file in the ingle nook f +ireplace";

In reply to Problem seeing multiline text in Excel cells by merrymonk

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.