Word.Documents.Save()和.SaveAs()都崩溃Word [英] Word.Documents.Save() and .SaveAs() both crash Word

查看:714
本文介绍了Word.Documents.Save()和.SaveAs()都崩溃Word的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定这是否是正确的论坛,因为我没有使用VSTO,我正在使用PIA for Word与我的程序进行交互。

无论如何,该程序的目的是打开模板,插入用户先前输入的数据,插入表格和图片,并保存文档。除非我尝试保存文档,否则一切正常。它总是抛出这个COMException:
$

I'm not sure if this is the correct forum to ask this because I'm not using VSTO, I'm using the PIA for Word to interface with my program.

Anyway, the purpose of the program is to open up a template, insert data previously entered by users, insert a table and a picture, and save the document. Everything works fine except when I try to save the document. It always throws this COMException:


System.Runtime.InteropServices.COMException occurred

  ErrorCode=-2147417851

  Message="The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))"

  Source="Microsoft.Office.Interop.Word"

  StackTrace:

       at Microsoft.Office.Interop.Word.DocumentClass.Save()

       at Project_Automation.Form1.cmdFinishDocument_Click(Object sender, EventArgs e) in ...Project Automation\Form1.vb:line 16201

推荐答案

你好詹姆斯,

你能和我们分享代码吗?如何创建新文档?通过使用Documents.Add()?据我所知,一般情况下,我们使用Documents.Add打开一个新文档,然后使用SaveAs / Save 方法保存此文档。对于Documents.Add方法和SaveAs方法,请参阅这些MSDN页面:  http:// msdn。 microsoft.com/en-us/library/bb237079.aspx  和 http:// msdn.microsoft.com/en-us/library/bb221597.aspx 。 

实际上,这个论坛不是这个问题的最佳选择。对于Word Automation问题,最好的地方是 Invate On Office论坛或Word新闻组。对于这个单词新闻组,你会在这个论坛的请先阅读

最好的问候,
Bessie
Hello James,

Would you please share the code with us? How you create a new document? by using Documents.Add()? As far as I see, in general, we use Documents.Add to open a new document, and then use SaveAs/Save method to save this document. For Documents.Add method and SaveAs method, please refer to these MSDN pages: http://msdn.microsoft.com/en-us/library/bb237079.aspx and http://msdn.microsoft.com/en-us/library/bb221597.aspx. 

Actually, this forum is not the best place for this issue. For Word Automation issue, the best place would be Invate On Office forum or Word newsgroup. For this word newsgroup, you will find an appropriate entry link in this forum's PLEASE READ FIRST.

Best regards,
Bessie


这篇关于Word.Documents.Save()和.SaveAs()都崩溃Word的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆