读书人

署理创建excel后台报错quot;Operation is

发布时间: 2012-12-31 11:57:51 作者: rapoo

代理创建excel后台报错"Operation is disallowed in theis session"
Sub Initialize
On Error Goto err_handle
Dim session As NotesSession
Dim docNew As NotesDocument
Dim ExcelApp As Variant
Dim ExcelBook As Variant
Dim ExcelSheet As Variant
Dim iCount As Integer


Set session = New NotesSession
Set docNew = session.DocumentContext
Set ExcelApp = createObject("excel.application")
ExcelApp.visible =False
Set ExcelBook = ExcelApp.WorkBooks.add
Set ExcelSheet = ExcelBook.WorkSheets(1)
ExcelSheet.cells(1,1).value = "姓名"
ExcelSheet.cells(1,2).value = "年龄"

For iCount =2 To 6
ExcelSheet.cells(iCount,1).value = iCount
ExcelSheet.cells(iCount,2).value = iCount
Next
ExcelApp.ActiveWorkbook.SaveAs("C:/")

ExcelBook.close(True)
ExcelApp.quit
Set ExcelApp =Nothing

Exit Sub

err_handle:
Msgbox "=============================================="
Msgbox ""+Error
Msgbox ""+Cstr(Erl())
Msgbox "=============================================="
End Sub
[解决办法]
ExcelApp.ActiveWorkbook.SaveAs("C:/test.doc")

要这样子写完整路径,是文件路径 not 文件夹路径。

读书人网 >行业软件

热点推荐