Public Sub MyFlexGridExport(MyFlexGrid As MSFlexGrid, FileName As String, Optional Delimiter As Variant = ";", Optional EncloseStrings As Variant)
Dim MyRows As Integer
Dim MyCols As Integer
Dim MyFileNumber As Integer
If IsMissing(Delimiter) Then
Delimiter = vbTab
End If
If IsMissing(EncloseStrings) Then
EncloseStirngs = ""
End If
MyFileNumber = FreeFile
Open FileName For Output As #MyFileNumber
For MyRows = 0 To MyFlexGrid.Rows - 1
MyFlexGrid.Row = MyRows
For MyCols = 0 To MyFlexGrid.Cols - 1
MyFlexGrid.Col = MyCols
'If it isn't the Min column,
'Put a delimiter before the value
If MyCols > 0 Then
Print #MyFileNumber, Delimiter;
End If
Print #MyFileNumber, EncloseStrings & MyFlexGrid.Text & EncloseStrings;
Next MyCols
Print #MyFileNumber, ""
Next MyRows
Close #MyFileNumber
End Sub
Private Sub cmdExport_Click()
Call MyFlexGridExport(MSFlexGrid1, "c: est.flex", ",", Chr$(34))
End Sub