ms-word

Apache poi get table from text box

邮差的信 提交于 2019-12-25 10:35:03
问题 I'm using apache poi for iteration table in docx file. All works fine but if table in text box , my code don't see table - table.size() = 0 XWPFDocument doc = new XWPFDocument(new FileInputStream(fileName)); List<XWPFTable> table = doc.getTables(); for (XWPFTable xwpfTable : table) { List<XWPFTableRow> row = xwpfTable.getRows(); for (XWPFTableRow xwpfTableRow : row) { List<XWPFTableCell> cell = xwpfTableRow.getTableCells(); for (XWPFTableCell xwpfTableCell : cell) { if(xwpfTableCell != null){

WinWord.exe won't close

二次信任 提交于 2019-12-25 09:40:58
问题 I am running into issues creating a Word document Word from Excel using Set wordapp = CreateObject("word.Application") Set letter = wordapp.Documents.Add On first run it works fine, on second run it hangs. I think the issue is if I close the document I created using the Close Button in Word, it won't close WinWord.Exe. I think it has to do with whether I saved the document or not. How can I get around this? I uninstalled/deactivated all of my Add-ins (I heard that could be an issue) to no

VBA update filename and path upon saving

折月煮酒 提交于 2019-12-25 09:36:16
问题 I've tried using the following codes below, but none will give me an active field that will update upon saving. I want the file path and name . Maybe you can help. Thanks. ActiveDocument.Name - gives the name of the document, without path information. 回答1: As @braX says Use FullName to get the file name and path. Note FullName will only contain the file path AFTER you have saved the document once! ' Saved ActiveDocument.FullName ' -> C:\Documents\Doc1.docx ' Unsaved ActiveDocument.FullName '

Unable to set Comobject Value

余生颓废 提交于 2019-12-25 09:16:12
问题 I have a snippet of code that opens a word template, then attempts to set values of named FormFields. $options = @{ 'foo' ='bar'; 'bizz' = 'buzz'; } $document = 'C:\Form_template.doc' $word = new-object -ComObject Word.application $doc = $word.Documents.Open($document) $word.visible = $true $fields = $doc.FormFields $fields.item('foo').Result = $options['foo'] $fields.item('bizz').Result = $options['bizz'] When running this snippet, the form fields are not set properly. However, when I run

Microsoft Word Interop: SaveAs hangs for some misterious argument types

梦想与她 提交于 2019-12-25 09:09:57
问题 When trying to simplify a PowerShell script that converts from Word to PDF, I found out the following weird scenario that blows my mind. Here's the transcript from a proof of concept interactive session: Windows PowerShell Copyright (C) 2016 Microsoft Corporation. All rights reserved. PS C:\Users\Frag> Add-Type -AssemblyName Microsoft.Office.Interop.Word PS C:\Users\Frag> $word = New-Object -ComObject Word.Application PS C:\Users\Frag> $i = Get-Item ".\document.docx" PS C:\Users\Frag> $i

Position/scale image after programmatically pasting it into bookmark range

心不动则不痛 提交于 2019-12-25 08:14:31
问题 I'm creating a Word 2010 document using C# and Microsoft.Office.Interop.Word . Using the Range.Paste method, I insert a bitmap (from RAM) at a specified bookmark: Word.Bookmark bookmark = document.Bookmarks.get_Item(ref oBookmark); Clipboard.SetDataObject(image); bookmark.Range.Paste(); This bookmark is placed inside a frame (created with the "Insert Frame" command), hence the pasted image is placed inside the frame. Now, the image is automatically scaled to fit the frame horizontally. This

How to make the first page in a section have different margins?

戏子无情 提交于 2019-12-25 08:11:25
问题 I'm using PHP to create Word documents. I've figured out how to set the page margins for a section. I've also figured out how to set headers and footers for the first page, even pages and default pages of a section. What I can't figure out is how to set the top margin of a page different for the first page in a section. Essentially, I have a larger header image on the first page of the section and need to push the top margin of that page down twice as far as the top margins on all the other

Word VBA Find/Replace Issue

心已入冬 提交于 2019-12-25 08:00:39
问题 Using the VBA Find and Replace in Word i have the issue that if i am trying to replace all instances of "John(space)Smith" for example, with "John(non-breaking space)Smith", the Find Replace function replaces all "John(space)Smith" as well as all "John(non-breaking space)Smith" with "John(non-breaking space)Smith". Before i am using this and leaving track changes i don't really want it to replace it with itself. I have tried using Chr(32) to only select the space but still to no avail. (I

Insert OOXML comment with track changes

北慕城南 提交于 2019-12-25 08:00:03
问题 In my Word add-in I am inserting comments by replacing the selected text with OOXML that contains the comment. With "Track Changes" turned on Word registers this as 3 actions: delete+insert+comment. It even inserts a paragraph break but I am unsure if that is related. Is there a way to only have it register as a comment action like when inserting a comment using Word functionality? Using rangeObject.insertOoxml I tried to insert at the beginning and at the end of the string without any luck

How to programmatically open a file located in OneDrive using desktop Word?

为君一笑 提交于 2019-12-25 07:48:03
问题 I have a .docx file in OneDrive . If I click on it, it opens on Word Online . Then, there is a button that says Edit in Word that opens the current file in desktop Word (you have to provide credentials, of course). Using the OneDrive API , I'm able to open a file directly in Word Online from my PHP application (since it provides the file URL), but now I'm trying to directly open it in Word Offline (and then, Word will prompt the credentials to the user). TL;DR: I'm trying to reproduce the