This code exports data from the DataGrid control to a *.csv file for MS Excel. This might not be pe
This code exports data from the DataGrid control to a *.csv file for MS Excel. This might not be perfect but it's a good start and it's more
Rate This code exports data from the DataGrid control to a *.csv file for MS Excel. This might not be pe
(1(1 Vote))
With dlgCommonDialog
.DialogTitle = "Save"
.CancelError = False
'ToDo: set the flags and attributes of the common dialog control
.Filter = "MS Excel CSV Files (*.csv)|*.csv" ' save as csv file
.ShowSave
If Len(.FileName) = 0 Then
Exit Sub
End If
sFile = .FileName
End With
'MsgBox sFile 'display the file path and name if desired.
Open sFile For Append As #1 'open the specified file
Dim strRecInfo As String
For i = 1 To adoPrimaryRS.RecordCount 'loop through records
For j = 0 To Me.grdDataGrid.Columns.Count - 1 'loop through columns
strRecInfo = strRecInfo & Me.grdDataGrid.Columns(j).Value & "," 'make data comma delimited
Next j
Print #1, strRecInfo
strRecInfo = ""
adoPrimaryRS.MoveNext
Next i
Close #1
This code exports data from the DataGrid control to a *.csv file for MS Excel. This might not be pe Comments
No comments yet — be the first to post one!
Post a Comment