'建立一模块
Public Sub Export(formname As Form, flexgridname As String)
Dim xlApp As Object 'Excel.Application
Dim xlBook As Object 'Excel.Workbook
Dim xlSheet As Object 'Excel.Worksheet
Screen.MousePointer = vbHourglass
On Error GoTo Err_Proc
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
'Begin to fill data to sheet
Dim i As Long
Dim j As Integer
Dim k As Integer
With formname.Controls(flexgridname)
For i = 0 To .rows - 1
k = 0
For j = 0 To .Cols - 1
If .colwidth(j) > 20 Or .colwidth(j) < 0 Then
k = k + 1
xlSheet.Cells(i + 1, k).Value = "'" & .TextMatrix(i, j)
End If
Next j
Next i
End With
xlApp.Visible = True
Screen.MousePointer = vbDefault
Exit Sub
Err_Proc:
Screen.MousePointer = vbDefault
MsgBox "请确认您的电脑已安装Excel!", vbExclamation, Ts