|
-
May 27th, 2003, 11:04 AM
#1
Thread Starter
Hyperactive Member
export column headers to a CSV file
I am using this code:
Write #1, List1.ListItems(i).Text, List1.ListItems(i).ListSubItems(1).Text, _
List1.ListItems(i).ListSubItems(2).Text, List1.ListItems(i).ListSubItems(3).Text, _
List1.ListItems(i).ListSubItems(4).Text, List1.ListItems(i).ListSubItems(5).Text
It works, but there could be more than the 4 rows. Is there a way of exporting this according to the number of columns (each has to be seperated by a comma and has to be one command)?
Write x, y, z, ...
I can get the column headers into a temp var, but it copies all headers into a single cell (spreadsheet)
For i = 1 To List1.ColumnHeaders.Count
tmpHeaders = tmpHeaders & "," & List1.ColumnHeaders(i).Text
Next i
thanks
-
May 27th, 2003, 11:32 AM
#2
Fanatic Member
You can just do a count of the number of row and columns that you have and then use a for loop to go through all of items like this untested code:
You can just do a count of the number of row and columns that you have and then use a for loop to go through all of items like this untested code:
Code:
InfoRow = List1.ColumnHeaders(1).Text
For i = 2 To List1.ColumnHeaders.Count
InfoRow = InfoRow & "," & List1.ColumnHeaders(i).Text
Next i
Write #1, InfoRow
For i = 1 To List1.ListItems.Count
InfoRow = List1.ListItems(i).ListSubItems(1).Text
For j = 2 To List1.ListItems(i).ListSubItems.Count
InfoRow = InfoRow & "," & List1.ListItems(i).ListSubItems(j).Text
Next j
Write #1, InfoRow
Next i
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|