|
我在用下面代码把窗体中数据导入到指定excel中,但是只可以导一列数据,怎么才可以导出多列数据呀,我把Fields()里的数改成2,就出现"这个集合中找不到此项目".哪位高手知道?(我的"温度子窗体"有2列数)
Dim oApp As Object
Set oApp = CreateObject("Excel.Application")
oApp.Visible = False
Set oappwork = oApp.Workbooks.Open("d:\温度模板.xls") '指定模板名称
Set oappwork_sheet1 = oappwork.Worksheets("sheet1")
With Me.[温度子窗体].Form.Recordset '导入窗体名称
.MoveFirst
nn = .Fields.Count '列数
j = 1 '由第几行导入
Do
If .EOF Then
Exit Do
Else
For i = 1 To nn-1
oappwork_sheet1.cells(j, 0 + i) = .Fields(i)
Next i
j = j + 1
.MoveNext
End If
Loop
MsgBox "数据已经导入EXCEL", vbOKOnly + vbInformation
oApp.Visible = True
End With
On Error Resume Next
oApp.UserControl = True
|
|