title: Server Agent not saving Excel file
body: <p>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.</p>
  
  <p>Error I get is:  </p>
  
  <blockquote>
    <p><strong>Agent Manager: Agent message: INITIALIZE:   - Error #213 - Microsoft Excel: SaveAs method of Workbook class failed @ line #37</strong></p>
  </blockquote>
  
  <p>We have Excel 2016 installed on Windows Server 2012. Domino Server version is 8.5.3 FP6</p>
  
  <p>Code using:</p>
  
  <pre><code>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 #" &amp; Err &amp; " - " &amp; Error$ &amp; " @ line #" &amp; Erl
          MsgBox strMsg
          xlApp.quit
          Exit Sub
  ENDOFCODE:
  
  End Sub
  </code></pre>
  
  <p>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 <code>xlApp.ActiveWorkbook.SaveAs("C:\Temp\MikesTest.xlsx")</code> and same issue.</p>