ms-word

Error when creating an instance of Word in VB.net

こ雲淡風輕ζ 提交于 2019-12-24 17:27:15
问题 I am getting an error when I run this app in VS 2010 (it works fine in VS 2008) Private Sub GenerateInvoice() Dim emptyObject As Object = System.Reflection.Missing.Value Dim wordApp As New Word.Application wordApp.Visible = True Dim InvoiceDoc As New Word.Document InvoiceDoc = wordApp.Documents.Add(InvoicePath, emptyObject, emptyObject, emptyObject) Dim totalFields As Integer = 0 For Each mergeField As Word.Field In InvoiceDoc.Fields The error occurs at the For Each line "Object reference not

Read the word document conent without using Microsoft office

ε祈祈猫儿з 提交于 2019-12-24 17:05:36
问题 I am using word documents for the population of random mails. But to read the content, we are using MS Word. But the scripts are quite slow because of its auto-recovery feature. My code is in powershell, is there any other alternative to read word docs? I tried to use wordpad but no success. 回答1: If they are docx files then they are an OpenXML format. Several solutions exists of reading docx files from code without requiring Office. See here and here. They are in C# but translating that to

How can I move cursor to end of table In word application

蹲街弑〆低调 提交于 2019-12-24 16:45:59
问题 I have a Word document with 2 pages and I've insert table that table start from page one and continues until the middle of the second page(Only one table exist in document). In Delphi(XE7) and with OLE automation(variant and Office 2013), How can I move cursor after the table? (Manually in word document file, I have repeatedly press Enter key) For this purpose, These codes will not work : Selection.GoTo(wdGoToItem.wdGoToPage, wdGoToDirection.wdGoToLast); and : Selection.EndKey(wdStory,

Trim() doesn't work with tables

一笑奈何 提交于 2019-12-24 16:25:17
问题 I had to solve a little problem today (trimming trailing whitespace in a MS Word document that the PDF converter had added to each and every cell), and I quickly found out that this isn't possible using the standard Word interface, so wrote a small VBA script: Sub TrimCellSpaces() Dim itable As Table Dim C As Cell For Each itable In ThisDocument.Tables For Each C In itable.Range.Cells C.Range.Text = Trim(C.Range.Text) Next Next End Sub I was surprised that not only did this fail to remove the

VBA: How to loop through labels (not on a userform)?

帅比萌擦擦* 提交于 2019-12-24 16:24:24
问题 My Word document has many ActiveX labels. [Not textboxes: my original title was in error.] I'd like a macro to loop through them to perform an action on each of them (changing the captions), but I don't know how to identify them. If they were on a userform, I'd say: For each aLabel in UserForm1.Controls But that doesn't apply in my case. 回答1: Assuming it is textboxes you're working with, per the title but not the question, the document's Shapes collection may be what you're after: Sub

Manipulating word docs (doc, docx, etc) in linux with php or ruby

丶灬走出姿态 提交于 2019-12-24 16:07:31
问题 I have users uploading word documents on my webpage. I need to open these documents, display them in html, and allow the user to download a manipulated version. My webserver allows me to use PHP and Rails. So a solution in either language would be acceptable. I have found numerous other posts in my research such as LiveDocx which seems to be more geared only towards creating word documents with known templates. And Java POI which isn't supported by my webserver. I have also found information

Apache POI Remove CTHyperlink [Low Level code]

試著忘記壹切 提交于 2019-12-24 16:00:24
问题 Continue with my actual bug: Remove XWPFHyperlinkRun Apache POI With this code: public void eliminarHyperLink(XWPFDocument doc){ XWPFHeaderFooterPolicy policy= doc.getHeaderFooterPolicy(); XWPFFooter footer = policy.getDefaultFooter(); List<XWPFParagraph> paragraphs = footer.getParagraphs(); boolean primero = false; for (XWPFParagraph xwpfParagraph : paragraphs) { List<XWPFRun> runs = xwpfParagraph.getRuns(); if(primero == true){ for (XWPFRun run : runs) { if(run instanceof XWPFHyperlinkRun)

Remove XWPFHyperlinkRun Apache POI

元气小坏坏 提交于 2019-12-24 15:45:15
问题 I have the same problem as this partner: how to remove a XWPFHyperlinkRun by poi I can't convert my .doc to .pdf because of that XWPFHyperlinkRun element. I can remove a simply run paragraph like this: for (XWPFParagraph xwpfParagraph : paragraphs) { for (int i = 0; i < xwpfParagraph.getRuns().size(); i++) { xwpfParagraph.removeRun(i); } } but hypertextlink don't...... If someone had a solution i will be really grateful. Thanks, regards. 来源: https://stackoverflow.com/questions/35075174/remove

Change a value in embedded xlsx with apache poi

谁都会走 提交于 2019-12-24 13:45:24
问题 I tried to change a value of a xlsx-file which is embedded in a docx-file with apache poi. Sadly, I havent found a proper solution to this problem. After running my programm, the new created docx-file with the embedded xlsx-table hasnt changed. Here is what I have tried so far: FileInputStream fis = new FileInputStream("old.docx"); XWPFDocument xdoc = new XWPFDocument(OPCPackage.open(fis)); System.out.println(xdoc.getAllEmbedds().get(0)); File file2 = new File("new.docx"); for (PackagePart

Word VBA: finding a set of words and inserting predefined comments

て烟熏妆下的殇ゞ 提交于 2019-12-24 13:24:03
问题 I need to automate the insertion of comments into a word document: searching for a predefined set of words (sometimes word strings, and all non case-sensitive) each to which I add a predefined comment. There are two word sets, with two goals: Wordset 1: identical comment for each located word Wordset 2: individual comments (I suggest new text based on the word identified) I have been semi-automating this with a code that IDs all identified words and highlights them, helping me through the