我有一个 Visual Studio 2010 VB.NET 4.0 Windows 应用程序项目。该代码正在填充 Word 2010 文档。在 30 到 60 个表格的区域中的任何位置以及在 30 到 50 个嵌入图表的区域中的任何位置(都定义为内联形状 ( InlineShape
))。
Document.Save()
当我收到以下错误时,我不得不开始定期拨打电话: There are too many edits in the document. This operation will be incomplete. Save your work.
. 有足够的可用磁盘空间和内存。
在大多数情况下,调用.Save()
时会随机显示另存为对话框.Save()
。作为旁注,如果我单击取消,则会引发以下错误:Command failed at Microsoft.Office.Interop.Word.DocumentClass.Save()
.
这是代码的摘录,可让您了解正在发生的事情:
Imports _word = Microsoft.Office.Interop.Word
...
...
Dim wrd As _word.Application = CreateObject("Word.Application")
wrd.Visible = True
wrd.ScreenUpdating = True
Dim doc As _word.Document = wrd.Documents.Open("C:\my-file-template.docx")
doc.Application.DisplayAlerts = _word.WdAlertLevel.wdAlertsNone
doc.Range.NoProofing = True
Dim reportFilePathName As String = "C:\my-file.docx"
If File.Exists(reportFilePathName) Then
File.Delete(Me.reportFilePathName)
End If
doc.SaveAs2(reportFilePathName)
...
'Numerous tasks carried out
...
doc.Save() 'This may or may not cause the save as dialog to show
...
有人知道为什么会显示另存为对话框吗?我能阻止它吗?
是否有原因导致我收到“编辑过多”错误,因此不需要进行如此多的保存(这无论如何都会减慢进程!)?