word-automation

How can I call documents.open and avoid the 'file in use' dialog?

杀马特。学长 韩版系。学妹 提交于 2019-12-11 00:46:40
问题 I am writing some very simple code to open a word document, save it in a new format and close document. However I run into problems if the document has been left in a locked state and get the 'File in Use' dialog. Now I would be delighted to pick option 1 or 3 automatically, but can't seem to find a way. Ideally I would prevent it from showing at all via a parameter on the open method. I'm using Delphi, but that's not really relevant. Wordapp.documents.Open(InputFile); 回答1: Calling open with

Word Automation - File is in use by another application or user

安稳与你 提交于 2019-12-07 02:48:58
问题 I have a WinForms application where I am using Word Automation to build documents via a template, and then save them to the database. After the document is created, I retrieve the document from the database, write it to the file system in a temp directory, and then open the document using the Word Interop services. There is a list of documents loaded and the user can open only 1 instance of each document, but can open multiple different documents simultaneously. I don't have any problems with

Server-side word automation

萝らか妹 提交于 2019-12-04 20:51:54
I am looking for alternatives to using openxml for a server-side word automation project. Does anyone know any other ways that have features to let me manipulate word bookmarks and tables? I am currently doing a project of developing a word automation project for my company and I am using DocX Very simple and straight forward API to work with. The approach I am using is, whenever I need to work with XML directly, this API has a property named "xml" in the Paragraph class which gives you access to the underlying xml direclty so that I can work with it. The best part is its not breaking the xml

Inserting text after a bookmark in openxml

╄→尐↘猪︶ㄣ 提交于 2019-12-03 13:39:43
I am looking for a way to insert some text after a bookmark in a word doc using openxml. So far, i have been able to locate the bookmark using the following: var bookmarks = mainPart.Document.Descendants<BookmarkStart>().ToList(); var bookMarkToWriteAfter = bookmarks.FirstOrDefault(bm => bm.Name == insertAfterBoomark.Name); This bookmark in the word doc is a selection of two lines in the doc. I have to insert some text right after the two line selection. I have tried to insert text using the following: var run = new Run(); run.Append(new Text("Hello World")); bookMarkToWriteAfter .Parent

Using Sharepoint Word Automation to do a text replace

笑着哭i 提交于 2019-12-01 12:44:26
I am working with sharepoint 2010, what I am trying to do is take a word document template, do a replace on a few key words (ex: replace ##ClientID## with the id of the client) and save it with a specific name in a library on sharepoint. I have figured out how to do this on a local computer with word interop, however the word interop library is not designed to be run as a service. I then discovered Word Automation Services which appear to do what I need to do. However every example I find on the internet (including here on SO) is just "How to convert from a word document to xxx" using the

Improve performance of Search Replace in Word document using OLE and Delphi

↘锁芯ラ 提交于 2019-11-30 23:15:03
问题 After some experiments I ended up with the following code to perform Search and Replace in MSWord. This code works perfectly also in header and footer, including the cases in which header and/or footer are different for the first page or odd/even pages. The problem is that I need to call MSWordSearchAndReplaceInAllDocumentParts for every string I replace, and I get an unacceptable performance (2 minutes for about 50 strings in a 4 pages doc word). Ideally it should be "instantaneous" of

OpenXML Add paragraph style (Heading1,Heading2, Head 3 Etc) to a word processing document

你离开我真会死。 提交于 2019-11-30 14:20:36
问题 Can anybody guide me how to add predefined styles on paragraph using open XML Word Processing? I have tried various solutions available on forums but nothing works for me. Here is what i want to accomplish: // Create a document by supplying the filepath. WordprocessingDocument wordDocument = WordprocessingDocument.Create("E:/Test/Executive.Docx", WordprocessingDocumentType.Document); // Add a main document part. MainDocumentPart mainPart = wordDocument.AddMainDocumentPart(); // Create the

OpenXML Add paragraph style (Heading1,Heading2, Head 3 Etc) to a word processing document

不打扰是莪最后的温柔 提交于 2019-11-30 09:41:15
Can anybody guide me how to add predefined styles on paragraph using open XML Word Processing? I have tried various solutions available on forums but nothing works for me. Here is what i want to accomplish: // Create a document by supplying the filepath. WordprocessingDocument wordDocument = WordprocessingDocument.Create("E:/Test/Executive.Docx", WordprocessingDocumentType.Document); // Add a main document part. MainDocumentPart mainPart = wordDocument.AddMainDocumentPart(); // Create the document structure and add some text. mainPart.Document = new Document(); Body body = mainPart.Document