首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 企业软件 > 行业软件 >

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

2012-02-25 
代理创建excel后台报错Operation is disallowed in theis sessionSub InitializeOn Error Goto err_hand

代理创建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 文件夹路径。

热点排行