WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Excel
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Wrap Text in Excel Cell


Question:

How can I add the "Wrap Text" attribute to a particular cell in Excel?

Answer:

The code would look something like this:
Cell = "A1"
XLS = "C:\Temp\Data\Test.xls"
objXL = ObjectCreate("Excel.application")
objXL.Visible=@TRUE ;Change to @FALSE to hide
objXL.UserControl=@TRUE
objWBKs = objXL.Workbooks
objWBK = objWBKs.Open(XLS)

;Wrap text in cell A1
objXL.Range(Cell).Select
objXL.Selection.WrapText = @TRUE
Message("Notice",StrCat("Cell ",Cell, " Cell Format has been changed to Wrap Text."))

;Save changes
objXL.ActiveWorkbook.Save()

;Cleanup
objXL.Quit
objWBK = 0
objWBKs = 0
objXL = 0


Article ID:   W17166
File Created: 2007:07:03:14:28:34
Last Updated: 2007:07:03:14:28:34