大侠帮忙!关于VB调用EXCEL的问题!以前还好好的,不知怎么不行了!
本帖最后由 wangzhenkai1981 于 2013-02-19 08:58:42 编辑 Private Sub daochu_Click()
Static xlApp As Object
Static xlBook As Excel.Workbook
Static objWorksheetDel As Excel.Worksheet
Static HeadRange As Excel.Range
Static NewRange As Excel.Range
Static PicObject As Excel.ShapeRange
Set xlApp = CreateObject("Excel.application")
If Err.Number <> 0 Then
Set xlApp = New Excel.Application
Err.Clear
End If
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Add
xlApp.DisplayAlerts = False
Set objWorksheetDel = xlApp.ActiveSheet
Set xlSheet = xlBook.Worksheets("Sheet1")
r = 1
xlBook.Worksheets("Sheet1").Cells(1, 1) = "编号"
xlBook.Worksheets("Sheet1").Cells(1, 2) = "物品"
xlBook.Worksheets("Sheet1").Cells(1, 3) = "事件日期"
xlBook.Worksheets("Sheet1").Cells(1, 4) = "事件"
xlBook.Worksheets("Sheet1").Cells(1, 5) = "事件天数"
xlBook.Worksheets("Sheet1").Cells(1, 6) = "剩余天数"
xlBook.Worksheets("Sheet1").Cells(1, 7) = "标注"
If rptdata.EOF = False Then
rptdata.MoveFirst
End If
While Not rptdata.EOF
For c = 0 To 6 '列循环
xlBook.Worksheets("Sheet1").Cells(r + 1, c + 1) = rptdata.Fields(c) '保存到EXCEL
Next c
rptdata.MoveNext
r = r + 1
Wend
xlApp.DisplayAlerts = False '不进行安全提示
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
出现错误提示:自动化错误 对象库未注册
请哪位大侠帮忙指点!就20分,纯粹算帮忙吧!
[解决办法]
重装下OFFICE