I’m investigating an issue that one of my colleagues experiencing. Background on the issue is that we have an .net application function which opens a word document template, save the word document in a temporary folder in user’s PC and let the user edit the document. Once everything is done, the document saves upon closing. However, sometimes when user open the document it leads to Command Failed
error. However, this is an intermittent issue where the same user can open other documents. When I tried to isolate the issue, following code black leads to the error and I think the issue is with
masterDocument.SaveAs (AddBackslash(Settings.WorkingFolder) & fileNameString)
lead to the error. But as per my understanding the code is okay and the issue is only happening on certain documents. (Another user can open the same document without an issue)
If (myDoc) Then
WaitForm.Message = "Saving..."
WaitForm.masterDocument.Activate
Call SetDocumentProperty(masterDocument, "ENVIRONMENT", Settings.Environment)
' Get the name of the output file, and if we need to add the date to it
Dim fileNameString As String
fileNameString = XMLData.Data.Settings.OutputName
If (XMLData.Data.Settings.AppendDateToOutputName) Then
If (InStrRev(fileNameString, ".") > 0) Then
fileNameString = Replace$(fileNameString, ".", "_" & Format$(Now(), "yyyymmdd_HHnnss") & ".")
Else
fileNameString = fileNameString & Format$(Now(), "yyyymmdd_HHnnss")
End If
End If
' Save the document
On Error Resume Next
masterDocument.SaveAs (AddBackslash(Settings.WorkingFolder) & fileNameString)
If (Err.Number = 0) Then
outputFileName = AddBackslash(Settings.WorkingFolder) & fileNameString
Else
myDoc = False
g_strLastError = "Failed saving document '" & fileNameString & "'. Error:" & Err.Description
Call WinLog.Log(OBJECT_NAME, "Run", g_strLastError)
End If
On Error GoTo Run_Err
End If