Excel - Wrap text in cells

Hi.

I am working on an excel export from a wiev. The agent takes the content of the view and exports it out to an excel sheet.

This works fine, but how do get it to wrap the text in the excel sheet ? I want it to export 100 characters, then create a new line and continue with the text there.

How do I do that ?

Any suggestions ?

regards

Roger Hansen

Subject: Excel - Wrap text in cells.

If ‘excelApp’ is the excel object and you want to wrap the G row then the req. code is:

excelApp.Columns(“G:G”).EntireColumn.AutoFit

Similarly , write code as per as your requirement.

Subject: RE: Excel - Wrap text in cells.

Hi,

Thanks for your suggestion.

This works already, what I want is to have the text to span several lines insted of one long line.

If the text has 300 characters, I want the cell to contain three lines with 100 characters instead of one line with 300 characters…

Regards

Roger Hansen

Subject: RE: Excel - Wrap text in cells.

Roger,

When you have selected your cell range, you should be able to use the properties ColumnWidth to set the number of characters you would like the cell to be and the WrapText property of the range to set the cells in question to wrap the text (by setting it to true)

Unfortunately, i don’t have any code to give you, but this should work. Check the VBA help in Excel for more info.

Brandt

Subject: Excel - Wrap text in cells.

To wrap text try - excelApp.ActiveSheet.Range(“A1”).WrapText = True

To size a column try -

excelApp.ActiveSheet.Range(“A1”).Width = 100 (in points, don’t know if a point is the same size as a character, you’ll have to experiment with this one)

Or

excelApp.ActiveSheet.Columns(columnLetter).ColumnWidth = 100 (again, not sure of the size here)

Also, you can find an excel class at:

http://www.keithstric.com/A55BAC/keithstric.nsf/downloads/KSTD-762K98

There is a constants database over on OpenNTF here:

http://www.openntf.org/Projects/pmt.nsf/ProjectLookup/Microsoft%20Constants%20Database

HTH

Keith

http://www.keithstric.com