Ошибка при получении команды 0x800a1066 в Microsoft.Office.Interop.Word.DocumentClass.Save - PullRequest
0 голосов
/ 22 ноября 2018

Я использую Word VSTO AddIn, код которого ниже

Private Sub WordApp_DocumentBeforeClose(doc As Microsoft.Office.Interop.Word.Document, <Runtime.InteropServices.OutAttribute> ByRef Cancel As Boolean) Handles mWordApp.DocumentBeforeClose

    Try

        If Not Globals.ThisAddIn.EnableWordAddIn Then Return

        If mManagedDocuments.ContainsKey(doc.DocID) Then

            Dim closingDocument As PRADocument = mManagedDocuments(doc.DocID)

            If closingDocument IsNot Nothing Then

                ' Make sure we don't display this message for a none PRA document
                If closingDocument.IsPRADocument AndAlso Not closingDocument.WordDocument.ReadOnly Then
                    If Not closingDocument.WordDocument.Saved Then
                        ' 120020: "Do you want to save file ‘{0}’?"
                        If AddInMessageBox.Show(120020, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, closingDocument.WordDocument.Name) = DialogResult.Yes Then
                            closingDocument.WordDocument.Save()
                        Else
                            closingDocument.WordDocument.Saved = True
                        End If
                    End If

                    If closingDocument.ExpandedState = ExpandContractState.Expanded Then
                        ' If document is expanded when closing then contract it
                        DocumentExpandContract.ContractDocument(Globals.ThisAddIn.Application, closingDocument)
                        ' The expanded document will have been opened, but since we were closing we should close Word
                        mWordApp.Quit(False)
                        Return
                    End If

                ElseIf closingDocument.IsPRADocument AndAlso closingDocument.WordDocument.ReadOnly Then
                    ' If read-only don't prompt to save
                    closingDocument.WordDocument.Saved = True
                End If

            End If

            HandleDocumentClose(doc)

        End If

    Catch ex As Exception
        Util.DisplayException(ex)
    End Try

End Sub

Ошибка при получении команды 0x800a1066 в Microsoft.Office.Interop.Word.DocumentClass.Save после закрытия документа.

Не могли бы вы помочь мне проанализировать, что может вызвать эту ошибку?

Эта ошибка периодически и не воспроизводится каждый раз.

...