WinWord.exe won’t quit after calling Word.Documents.Add – Word .NET Interop

(All of my advice is adapted from this answer about Excel interop.) There are a few important things here: 1) Never use 2 dots on the same line. Also consider an indexer as a dot Good Word.Documents d = wordApp.Documents; Word.Document aDoc = d.Open(/*…*/); BAD Word.Document aDoc = wordApp.Documents.Open(/*…*/); 2) Release all of your pointers. … Read more

Inserting newlines in Word using OpenXML

To insert newlines, you have to add a Break instance to the Run. Example: run.AppendChild(new Text(“Hello”)); run.AppendChild(new Break()); run.AppendChild(new Text(“world”)); The XML produced will be something like: <w:r> <w:t>Hello</w:t> <w:br/> <w:t>world</w:t> </w:r>

Extract Data from Word Document to an Excel SpreadSheet

here’s some code making use of late binding (declare objects rather than word.application etc). From Excel 2003, it opens a WORD document searches for string “minimum stock” moves the cursor some lines/words further expands/selects the WORD cursor pastes this WORD selection into EXCEL steps 2-5 are repeated for “Period of report:” (note that the “:” … Read more

What is behind this difference in parentheses effect in VBA?

Definitely don’t introduce a “throw-away variable”, especially if it’s not declared, and especially if what you’re invoking is a Sub, a procedure that doesn’t return any value. Well you can, if you don’t mind a compile-time error: Expected Function or variable. Now… this behavior is extensive throughout VBA. It’s not specific to the SetHeight method. … Read more

How can I view/open a word document in my browser using with PHP or HTML

Two options: First is to just link to it, e.g. <a href=”https://stackoverflow.com/questions/4346117/MyWordDocument.doc”>My Word Document</a>, the second is to use an iframe and point it to the document. For this to work, however, most browsers require that the server sends a Content-disposition: inline header with the document. If you cannot configure your web server to do … Read more