当前位置: 代码迷 >> Lotus >> 代理创建excel后台报错"Operation is disallowed in theis session"该怎么解决
  详细解决方案

代理创建excel后台报错"Operation is disallowed in theis session"该怎么解决

热度:187   发布时间:2016-05-05 07:20:48.0
代理创建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 文件夹路径。
  相关解决方案