Dim rs As ADODB.Recordset '数据集 Dim newxls As Excel.Application 'Excel 应用程序 Dim newbook As Excel.Workbook '工作薄 Dim newsheet As Excel.Worksheet '工作表 Private Sub Command1_Click() Set newxls = CreateObject("Excel.Application") newxls.Visible = True Set newbook = newxls.Workbooks.Add '创建工作薄 Set newsheet = newxls.Worksheets.Add For i = 0 To rs.RecordCount - 1 For j = 0 To rs.Fields.Count - 1 DataGrid1.row = i DataGrid1.col = j newsheet.Cells(i + 4, j + 1) = DataGrid1.Text Next j Next i End Subrs没有定义你应该有定义!
Dim newxls As Excel.Application 'Excel 应用程序
Dim newbook As Excel.Workbook '工作薄
Dim newsheet As Excel.Worksheet '工作表
Private Sub Command1_Click()
Set newxls = CreateObject("Excel.Application")
newxls.Visible = True
Set newbook = newxls.Workbooks.Add '创建工作薄
Set newsheet = newxls.Worksheets.Add
For i = 0 To rs.RecordCount - 1
For j = 0 To rs.Fields.Count - 1
DataGrid1.row = i
DataGrid1.col = j
newsheet.Cells(i + 4, j + 1) = DataGrid1.Text
Next j
Next i
End Subrs没有定义你应该有定义!