服务器代理未保存Excel文件
我无法使用下面的代码在带有计划代理的服务器上保存Excel工作簿,但当我在本地运行它时,它会工作 我得到的错误是: 代理管理器:代理消息:初始化:-错误213-Microsoft Excel:工作簿类的另存为方法失败@line\37 我们在Windows Server 2012上安装了Excel 2016。Domino服务器版本是8.5.3 FP6 代码使用:服务器代理未保存Excel文件,excel,lotus-notes,lotusscript,Excel,Lotus Notes,Lotusscript,我无法使用下面的代码在带有计划代理的服务器上保存Excel工作簿,但当我在本地运行它时,它会工作 我得到的错误是: 代理管理器:代理消息:初始化:-错误213-Microsoft Excel:工作簿类的另存为方法失败@line\37 我们在Windows Server 2012上安装了Excel 2016。Domino服务器版本是8.5.3 FP6 代码使用: Declarations Dim xlApp As Variant, xlsheet As Variant, rows As Integ
Declarations
Dim xlApp As Variant, xlsheet As Variant, rows As Integer, cols As Integer, xlWorkBk As Variant
Dim SheetRows() As Integer 'the bound for sheetRows is the same as the sheetNukmber
Sub Initialize
On Error GoTo ErrorTrap
Dim st As String, aname As String, sname As String
st = CStr(GetThreadInfo(1)) + ": "
Dim sess As New NotesSession ,db As NotesDatabase
Dim agent As NotesAgent
Dim v As NotesView, vString As String, strMsg As String
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument, maxcols As Integer
Dim a As Integer, range As String
Dim mgrList() As String, mgrTotal() As Currency
Dim x As Integer, mgrPcntg() As Double'GET SERVER NAME (COMMON)
Set db = sess.CurrentDatabase 'link to current database
If InStr(db.server,"/") Then
sName = Left(db.Server,InStr(db.server,"/")-1)
Else
sName = db.server
End If
'GET AGENT NAME (COMMON)
Set agent = sess.currentAgent
If InStr(agent.name,"|") Then
aName = Left(agent.name,InStr(agent.name,"|")-1)
Else
aName = agent.Name
End If
Set xlApp = CreateObject("Excel.Application") 'start Excel with OLE Automation
xlApp.Visible = False
xlApp.Workbooks.Add
'- - - - - - Adding data from Notes here - - - - -
'- - - - - - formatting worksheet - - - - - -
'- - - - - - I Get Error 213 at Next Line - - - - - -
'INITIALIZE: - Error #213 - Microsoft Excel: SaveAs method of Workbook Class failed @ Line #37
Call xlApp.ActiveWorkbook.SaveAs("C:\Temp\MikesTest.xlsx", 51) ',51)
xlApp.Quit
GoTo EndOfCode
ERRORTRAP:
strMsg = st + " - Error #" & Err & " - " & Error$ & " @ line #" & Erl
MsgBox strMsg
xlApp.quit
Exit Sub
ENDOFCODE:
End Sub
已检查代理签名者的权限,并且该权限是允许的。已选中文件文件夹限制,但没有限制。在互联网上搜索了数小时,但没有找到解决方案。
尝试了
xlApp.ActiveWorkbook.SaveAs(“C:\Temp\MikesTest.xlsx”)
和相同的问题。我不确定问题是什么,但可能是xlApp
对象的ActiveWorkbook
属性在服务器上工作的远程上下文中可能没有意义。而是在打开新工作簿时,将其分配给一个变量,然后直接使用该工作簿对象变量保存它:
Set xlApp = CreateObject("Excel.Application") 'start Excel with OLE Automation
xlApp.Visible = False
Dim xlWB As Object
Set xlWB = xlApp.Workbooks.Add
xlWB.SaveAs("C:\Temp\MikesTest.xlsx", 51) ',51)
Set xlWB = Nothing
xlApp.Quit
通过对我们的服务器进行一些更改,使其正常工作。 从Windows 2008开始,Microsoft更改了安全模型。IBM提供了极大的帮助,尽管这不是他们的问题。这就是我们所做的。 1.对于IBM Domino服务,更改了“登录”选项卡下的属性以使用帐户登录。 2.停止并重新启动Domino服务。 3.我们添加了以下目录“C:\Windows\SysWOW64\config\systemprofile\Desktop”。
4.已将文件保存到此目录。您说过c:\temp没有文件夹限制,这是否意味着任何人(包括Domino使用的服务帐户)都可以保存到该目录?能否在该文件夹中创建文本文件?访问服务器上的文件夹时使用的Windows用户名是否与在本地服务器上运行时使用的用户名/工作站相同?确保Windows文件夹本身的安全权限允许服务器用户修改其中的文件。C:\Temp文件夹属性中的安全性表示系统具有完全控制权。不幸的是,我们不得不将服务器作为应用程序而不是服务运行,因此运行Domino服务器的用户名位于Active Directory中。只有这样,代理才能在后台工作。如果您确实想到了一种让系统能够访问Domino服务器的应用程序的方法,请告诉我。干杯。通过对我们的服务器进行一些更改,使其正常工作。从Windows 2008开始,Microsoft更改了安全模型。IBM提供了极大的帮助,尽管这不是他们的问题。这就是我们所做的。对于IBM Domino服务,更改了“登录”选项卡下的属性以使用帐户登录。停止并重新启动Domino服务。接下来,我们添加了以下目录“C:\Windows\SysWOW64\config\systemprofile\Desktop”。成功了。