|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Dim objExcelApp
Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible = 1
objExcelApp.Workbooks.Open "D:\1.xlsx"
Dim conn, constr
constr = "Provider=SQLOLEDB.1;Password=0;Persist Security Info=True;User ID=sa;Initial Catalog=1031"
Set conn = CreateObject("ADODB.Connection")
conn.Open constr
Dim rsIS
Set rsIS = CreateObject("ADODB.Recordset")
rsIS.Open "SELECT * FROM T_BD_Material", conn
Dim i, j
For i = 0 To 24
For j = 0 To 24
objExcelApp.Cells(i, j).Value = rsIS(j).Value
Next
rsIS.MoveNext
Next
rsIS.Close
rsIS = Nothing
conn.Close
conn = Nothing
objExcelApp.Workbooks(1).Close
objExcelApp.Quit
End Sub
objExcelApp.Cells(i, j).Value = rsIS(j).Value 这条提示应用程序的定义或对象定义错误
求高手解决
|
|