服务器代理未保存Excel文件
我无法使用下面的代码将Excel工作簿保存在具有预定代理的服务器上,但是在本地运行时可以使用.
I am unable to save an Excel workbook using the code below on a server with a scheduled agent but it works on when I run it locally.
我得到的错误是:
代理管理器:代理消息:初始化:-错误#213-Microsoft Excel:工作簿类的SaveAs方法在@第37行失败
我们在Windows Server 2012上安装了Excel2016.Domino服务器版本为8.5.3 FP6
We have Excel 2016 installed on Windows Server 2012. Domino Server version is 8.5.3 FP6
代码使用:
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
已检查代理签名者的权限,并且允许.已检查文件夹限制,没有限制.在Internet上搜索了数小时,但未成功找到解决方案.尝试过 xlApp.ActiveWorkbook.SaveAs("C:\ Temp \ MikesTest.xlsx")
和相同的问题.
Checked permissions of agent signer and it is allowed. Checked file folder restrictions and there is none. Searched Internet for hours with no success in finding solution.
Tried xlApp.ActiveWorkbook.SaveAs("C:\Temp\MikesTest.xlsx")
and same issue.
通过对我们的服务器进行一些更改,使其可以正常工作.从Windows 2008开始,Microsoft更改了安全模型.尽管这不是他们的问题,IBM还是非常有帮助的.这就是我们所做的.1.对于IBM Domino Service,将登录"选项卡下的属性更改为使用帐户登录.2.停止并重新启动Domino服务.3.我们添加了以下目录C:\Windows\SysWOW64\config\systemprofile\Desktop".4.将文件保存到此目录.
Got it to work by making a few changes to our server. Starting with Windows 2008, Microsoft changed security model. IBM was extremely helpful although this is not their problem. This is what we did. 1. For the IBM Domino Service, changed the properties under the Log On tab to use an account to log on. 2.Stopped and restarted the Domino service. 3.We added the following directory "C:\Windows\SysWOW64\config\systemprofile\Desktop". 4. Saved the file to this directory.