Tag: ms word

是否可以更新使用Syncfusion的DocIO lib生成的Word文档的TOC(TableOfContents)?

我们的应用程序使用Syncfusion的DocIO库生成Word文档。 基本上,我们加载模板并在其中插入特定书签中的特定文本,生成用户即时下载的Word文档。 我们面临的问题是: 该模板长4页,具有TOC。 随着我们添加内容,页面中的文档大小增加(自然) 下载文档时,TOC仍会反映模板中使用的页码。 换句话说,用户必须手动更新TOC(辅助点击 – >更新字段)才能刷新页码。 根据Syncfusion的文档(很少……),使用他们的lib是不可能的。 因此,我们在模板中实现了一个AutoOpen宏,当打开文档作为变通方法时,它会更新TOC。 但是,这会在打开文件时导致安全警告(因为宏),这使我们的使用感到不舒服。 你们有没有想过改进这个实现? 谢谢,

如何在将图片插入word文档后更改图片的大小

我正在将图片添加到某个书签的word文档中。 但是,图片太大并且正在强制文本离开页面,所以我需要能够在word文档中更改图片的大小。

仅在尝试使用Word DocumentClass时在prod中获取对象引用错误

我正在编写一个使用.dotx模板的程序,并在aspx页面中进行数据合并。 该程序在我的开发工作站本地工作完美,但当我将它部署到测试IIS服务器时,它在下面的第二行失败,给我一个对象参考错误。 我之前遇到问题,因为Word Com对象不在IIS服务器上,因此我将Word加载到服务器上并在DCom中设置权限并解决了该问题。 但现在我在以wRange = …..开头的行上出现此错误 正如我所说,该程序在调试模式下完美地工作。 有任何想法吗? Microsoft.Office.Interop.Word.DocumentClass System.NullReferenceException: Object reference not set to an instance of an object 代码行: Document BaseDocument = oWord.Documents.Open(ref oTemplate, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, […]

COMException(0x800A13E9) – Word互操作服务

我得到这个堆栈跟踪: System.Runtime.InteropServices.COMException (0x800A13E9): Word ðú÷ì ááòéä. at Microsoft.Office.Interop.Word.Documents.Add(Object& Template, Object& NewTemplate, Object& DocumentType, Object& Visible) at Crm.DocumentGeneration.Printing.DocumentsPrinter.MergeDocuments(ApplicationClass& wordApp, IEnumerable`1 printDataItems, String tempDirectory, String template) in C:\Work\Danel.Nursing\Crm.DocumentGeneration.Printing\DocumentsPrinter.cs:line 249 谷歌搜索后似乎COMException(0x800A13E9)内存不足exception,但服务器上有足够的内存来启动太空船 8192太空飞船。 这是函数调用: Document document = wordApp.Documents.Add(ref defaultTemplate, ref missing, ref missing, ref missing); 我检查过defaultTemplate没有null或无效。

VSTO 2007:如何确定范围的页面和段落编号?

我正在构建一个MS Word加载项,它必须从文档中收集所有评论气球并在列表中汇总它们。 我的结果将是一个ReviewItem类列表,其中包含Comment本身,段落编号和注释文本所在的页码。 我的部分代码如下所示: private static List FindComments() { List result = new List(); foreach (Comment c in WorkingDoc.Comments) { ReviewItem item = new ReviewItem() { Remark = c.Reference.Text, Paragraph = c.Scope. ???, // How to determine the paragraph number? Page = c.Scope. ??? // How to determine the page number? }; result.Add(item); } return […]

将文本发送到Microsoft Word 2010中的邮件合并字段

我正在使用以下代码将文本发送到一个简单的单词模板,我目前只用一个MergeField来设置它来测试我可以使用它。 我使用的代码如下: public static void ReplaceMailMergeField(string pWordDoc, string pMergeField, string pValue) { object docName = pWordDoc; object missing = Missing.Value; Word.MailMerge mailMerge; Word._Document doc; Word.Application app = new Word.Application(); app.Visible = false; doc = app.Documents.Open(ref docName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref […]

Word Automation:使用C#替换图像

我正在尝试使用c#和word自动化更改word文档中的文本和图像。 我已经让它工作正常,我在下面的代码片段做了类似的事情,但我甚至不知道如何开始替换图像。 任何帮助是极大的赞赏! 奥利弗 using Microsoft.Office.Interop.Word; … private static Application WordApp; private static object missing = System.Reflection.Missing.Value; private static object yes = true; private static object no = false; … object search; object replace; object replaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll; object filename = SourceFile; object destination = DestinationFile; Document d = WordApp.Documents.Open( ref filename, ref missing, ref […]

使用c#将word文件(.docx和doc)转换为.pdf无效

我正在使用visualstudio 2010,我正在尝试将word.docx文件转换为.pdf文件,并且在本地工作正常但在运行时在服务器上它显示错误为 Could not load file or assembly ‘office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies. The system cannot find the file specified. 我试过的是添加引用并放入bin文件夹 Microsoft.Office.Interop.Word.dll Microsoft.Office.Interop.Word.xml 如图所示 我的.cs代码是 Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application(); wordApp.Visible = false; // file from object filename =Server.MapPath(“word.docx”); // input // file to object newFileName = Server.MapPath(“pdf/document_to_read_tomorrow.pdf”); // output object […]

生成Word文档的缩略图

我有一个用户上传Word文档的网站,我想显示这些word文档的缩略图。 如果你们中的任何人都知道如何使用C#将Word文件的第一页显示为图像,请告诉我。 此外,如果您知道一个受信任的.NET库,可以将Word文件转换为不需要办公室互操作的图像。

将Word转换为HTML然后在网页上呈现HTML

我的管道中有一个艰难的项目,我不知道从哪里开始。 我的老板希望能够以HTML格式显示Word文档,它看起来与word文档相同。 经过一段时间的尝试让我在弹出窗口或灯箱中显示word文档后,他不得不删除将其转换为HTML的单词内容,将其保存在数据库中,然后在网页上将其显示为HTML 。 你们可以给我一些好的弹药,如果显示word文件更好(不那么繁琐,更少的存储空间更安全等)。 或者,如果将单词文档转换为HTML方式很容易让我这样做。 我目前拥有的技术是entity framework,LINQ,MVC,C#,Razor。 我们目前使用HTmlAgilityPack,但这会删除所有格式,并且不允许文档显示得很好。