ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vb project data exported to excel (https://www.excelbanter.com/excel-programming/406632-vbulletin-project-data-exported-excel.html)

confused[_5_]

vb project data exported to excel
 
Hello;
Can someone please tell me how to write the code I need to use word
wrap.
I have a vb 2005 app that exports the data into excel and I want the
data in each row to use word wrap for every text columm. The code
below only sets the column heading, I thought it would set all column
per row
(example cloumn a1 is name so all rows for a1 should be set with word
wrap)

SetColumnsFormat(oExcel)

Private Function SetColumnsFormat(ByVal oExcel As Object) As Boolean

For i As Integer = 0 To lstColumnsSelected.Items.Count - 1
Application.DoEvents()

Dim myExcel As Excel_ = oExcel

Dim col As dcColumn
col = lstColumnsSelected.Items.Item(i)
Dim nmLwr As String = col.Name.ToLower()

Select Case col.Type
Case 1
' Text Type R,Col Width
myExcel.WrapText(1, i + 1, True)
Continue For

Case 2 ' Date Type
myExcel.FormatWidth(1, i + 1, col.Width)
Continue For

Case 3 ' Hours Col Format
myExcel.FormatNum(i + 1, "###0")
myExcel.FormatWidth(1, i + 1, col.Width)
Continue For

Case 4 ' Money
myExcel.FormatNum(i + 1, "###,##0.00")
myExcel.FormatWidth(1, i + 1, col.Width)
Continue For

Case 5 ' Months
myExcel.FormatNum(i + 1, "##0.0")
myExcel.FormatWidth(1, i + 1, col.Width)
Continue For

Case Else
myExcel.FormatWidth(1, i + 1, col.Width)

End Select

Next i
End Function

What am I doing wrong?

confused[_5_]

vb project data exported to excel
 
On Feb 25, 10:27*am, confused wrote:
Hello;
Can someone please tell me how to write the code I need to use word
wrap.
I have avb2005 app that exports the data into excel and I want the
data in each row to use word wrap for every text columm. *The code
below only sets the column heading, I thought it would set all column
per row
(example cloumn a1 is name so all rows for a1 should be set with word
wrap)

SetColumnsFormat(oExcel)

Private Function SetColumnsFormat(ByVal oExcel As Object) As Boolean

* * * * For i As Integer = 0 To lstColumnsSelected.Items.Count - 1
* * * * * * Application.DoEvents()

* * * * * * Dim myExcel As Excel_ = oExcel

* * * * * * Dim col As dcColumn
* * * * * * col = lstColumnsSelected.Items.Item(i)
* * * * * * Dim nmLwr As String = col.Name.ToLower()

* * * * * * Select Case col.Type
* * * * * * * * Case 1
* * * * * * * * * * * ' Text Type R,Col * Width
* * * * * * * * * * myExcel.WrapText(1, i + 1, True)
* * * * * * * * * * Continue For

* * * * * * * * Case 2 * ' *Date Type
* * * * * * * * * * myExcel.FormatWidth(1, i + 1, col.Width)
* * * * * * * * * * Continue For

* * * * * * * * Case 3 * ' *Hours *Col * *Format
* * * * * * * * * * myExcel.FormatNum(i + 1, "###0")
* * * * * * * * * * myExcel.FormatWidth(1, i + 1, col.Width)
* * * * * * * * * * Continue For

* * * * * * * * Case 4 * ' *Money
* * * * * * * * * * myExcel.FormatNum(i + 1, "###,##0.00")
* * * * * * * * * * myExcel.FormatWidth(1, i + 1, col.Width)
* * * * * * * * * * Continue For

* * * * * * * * Case 5 * ' *Months
* * * * * * * * * * myExcel.FormatNum(i + 1, "##0.0")
* * * * * * * * * * myExcel.FormatWidth(1, i + 1, col.Width)
* * * * * * * * * * Continue For

* * * * * * * * Case Else
* * * * * * * * * * myExcel.FormatWidth(1, i + 1, col.Width)

* * * * * * End Select

* * * * Next i
* * End Function

What am I doing wrong?


Found my answer, doesn't seem to be much help on this group. Don't
know how to close this topic, if I could , I would

JP[_4_]

vb project data exported to excel
 
Maybe you should have posted this in a VB newsgroup?

--JP


On Feb 26, 3:26*pm, confused wrote:
On Feb 25, 10:27*am, confused wrote:





Hello;
Can someone please tell me how to write the code I need to use word
wrap.
I have a vb2005 app that exports the data into excel and I want the
data in each row to use word wrap for every text columm. *The code
below only sets the column heading, I thought it would set all column
per row
(example cloumn a1 is name so all rows for a1 should be set with word
wrap)



Found my answer, doesn't seem to be much help on this group. *Don't
know how to close this topic, if I could , I would

- Show quoted text -




All times are GMT +1. The time now is 07:03 AM.

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