Office中国论坛/Access中国论坛

标题: 求教:重装系统后调用execl属性出错 [打印本页]

作者: lyz0628    时间: 2009-5-6 17:21
标题: 求教:重装系统后调用execl属性出错
原本能正常运行的调用,但重装系统(XP)后,重装原版本的Office(2003),运行出错。提示为(运行时错误“-21473919779(8002801d)方法'CopyFromRecordset'作用于对象'Range'时失败)。程序如下:
Sub ±íÉú³É(StrRS2 As String, StrRs3 As String, TXT As String)
Dim Rs2 As Recordset, Conn2 As Connection
Dim objXL As Excel.Application
Dim xlWBWK As Excel.Workbook
Dim T As Integer
Set Rs2 = New ADODB.Recordset
Set Conn2 = CurrentProject.Connection
Rs2.Open StrRS2, Conn2, adOpenKeyset, adLockReadOnly
T = Rs2.RecordCount
If T > 0 Then
   Rs2.MoveFirst
   Set objXL = New Excel.Application
   Workbooks.Open Filename:=StrRs3
   Set xlWBWK = ActiveWorkbook
   Worksheets(TXT).Range("A2").CopyFromRecordset Rs2
   ActiveWorkbook.Save
   ActiveWorkbook.Close
   Set objXL = Nothing
Set xlWBWK = Nothing
End If
Rs2.Close
Set Rs2 = Nothing
Set objXL = Nothing
End Sub
作者: Henry D. Sy    时间: 2009-5-6 17:33
检查一下引用看看。
作者: todaynew    时间: 2009-5-6 17:34
把拷贝改成赋值语句试试
作者: lyz0628    时间: 2009-5-6 18:09
多谢,引用是没问题的,可以赋值,但由于数据库记录太多,速度太太慢
作者: lyz0628    时间: 2009-5-14 16:38
我自己顶下,求各位大侠出手出招,小弟在些谢了




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3