Function ExcelCellWrap()
On Error GoTo ErrHandler
Dim xl As Excel.Application
Dim wb As Excel.Workbook
Dim sht As Excel.Worksheet
Dim rng As Excel.Range
Set xl = New Excel.Application
Set wb = xl.Workbooks.Open("C:\TestWrap.xls")
Set sht = wb.Sheets("Sheet1")
Set rng = sht.Range("A1:H10")
With rng
.Value = "This is a long text string to test word wrapping..."
.WrapText = True
End With
xl.Visible = True
ExitHere:
Exit Function
ErrHandler:
MsgBox "Error: " & Err & " - " & Err.Description
Resume ExitHere
End Function