ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Turning off Word-Wrap (https://www.excelbanter.com/excel-programming/444458-turning-off-word-wrap.html)

WillisCat

Turning off Word-Wrap
 
If I write
Cells(3, 5).Value2 = :"a very long string of characters"
in Excel VBA, the result is that string of characters stored in cell
E3. Because the string is longer than the width of the cell, it
extends out of the cell into the cells to the right, if those cells
have no values. If I subsequently format the cell to be right-aligned,
the text begins in a cell to the left of E3. Just what I would expect.

However, if I do the same thing with a C++ program using OLE
automation, the long string is word-wrapped in cell E3 and the height
of row 3 is increased to contain the word-wrapped text.

Any idea why I get different results when the automation is controlled
by a C++ program rather than VBA? And more importantly, how can I
prevent this from happening?

I've tried using Value as well as Value2 and I've tried setting the
WordWrap property to False. No successes yet.

Willis

spilly39

Turning off Word-Wrap
 
I really have no experience, but I'd start looking at the cell formatting
properties in the two environments - Cell.WrapText is a boolean


"WillisCat" wrote in message
...
If I write
Cells(3, 5).Value2 = :"a very long string of characters"
in Excel VBA, the result is that string of characters stored in cell
E3. Because the string is longer than the width of the cell, it
extends out of the cell into the cells to the right, if those cells
have no values. If I subsequently format the cell to be right-aligned,
the text begins in a cell to the left of E3. Just what I would expect.

However, if I do the same thing with a C++ program using OLE
automation, the long string is word-wrapped in cell E3 and the height
of row 3 is increased to contain the word-wrapped text.

Any idea why I get different results when the automation is controlled
by a C++ program rather than VBA? And more importantly, how can I
prevent this from happening?

I've tried using Value as well as Value2 and I've tried setting the
WordWrap property to False. No successes yet.

Willis




All times are GMT +1. The time now is 11:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com