【问题标题】:Server Agent not saving Excel file服务器代理不保存 Excel 文件
【发布时间】:2018-03-05 16:40:35
【问题描述】:

我无法在具有计划代理的服务器上使用下面的代码保存 Excel 工作簿,但是当我在本地运行它时它可以工作。

我得到的错误是:

代理管理器:代理消息:初始化:- 错误 #213 - Microsoft Excel:工作簿类的 SaveAs 方法在第 37 行失败

我们在 Windows Server 2012 上安装了 Excel 2016。Domino Server 版本是 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

已检查代理签名者的权限并且是允许的。检查文件夹限制,没有。在互联网上搜索了几个小时,但没有成功找到解决方案。 试过xlApp.ActiveWorkbook.SaveAs("C:\Temp\MikesTest.xlsx") 和同样的问题。

【问题讨论】:

  • 您说在 c:\temp 上没有文件夹限制,这是否意味着任何人(包括 Domino 使用的服务帐户)都可以在那里保存?你能在那个文件夹中创建一个文本文件吗?
  • 用于访问服务器上文件夹的 Windows 用户名是否与在本地运行时使用的用户名/工作站相同?确保 Windows 文件夹本身的安全权限允许服务器用户修改其中的文件。
  • C:\Temp 文件夹属性中的安全性表明 SYSTEM 具有完全控制权。
  • 不幸的是,我们不得不将服务器作为应用程序而不是服务运行,以便运行 Domino 服务器的用户名位于 Active Directory 中。只有这样代理才能在后台工作。如果您确实想出了一种让 SYSTEM 让应用程序访问 Domino 服务器的方法,请告诉我。干杯。
  • 通过对我们的服务器进行一些更改使其工作。从 Windows 2008 开始,微软改变了安全模型。 IBM 非常有帮助,尽管这不是他们的问题。这就是我们所做的。对于 IBM Domino 服务,将“登录”选项卡下的属性更改为使用帐户登录。停止并重新启动 Domino 服务。接下来我们添加了以下目录“C:\Windows\SysWOW64\config\systemprofile\Desktop”。它奏效了。

标签: excel lotus-notes lotusscript


【解决方案1】:

通过对我们的服务器进行一些更改使其工作。 从 Windows 2008 开始,微软改变了安全模型。 IBM 非常有帮助,尽管这不是他们的问题。这就是我们所做的。 1. 对于 IBM Domino 服务,将登录选项卡下的属性更改为使用帐户登录。 2.停止并重新启动 Domino 服务。 3.我们添加了以下目录“C:\Windows\SysWOW64\config\systemprofile\Desktop”。 4. 将文件保存到该目录。

【讨论】:

    【解决方案2】:

    我不确定问题出在哪里,但它可能是 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
    

    【讨论】:

      猜你喜欢
      • 2014-01-07
      • 1970-01-01
      • 1970-01-01
      • 2011-10-27
      • 2012-09-03
      • 2020-09-20
      • 2011-02-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多