c# windows application Working with Microsoft Office Word
-
Hi, We have a C# windows forms application and I need to work with MS Word files to replace some text, table rows content, or add a new rows to an existed table, we need to know the best way. I tried using Microsoft.Office.Interop.Word but this way may be old and must use the same office on the all pc's you install the application on it, if you use the MS Office 2007 then you must install it on any PC will use the application. Please let me know the best way, tools to do that. Thank You
-
Hi, We have a C# windows forms application and I need to work with MS Word files to replace some text, table rows content, or add a new rows to an existed table, we need to know the best way. I tried using Microsoft.Office.Interop.Word but this way may be old and must use the same office on the all pc's you install the application on it, if you use the MS Office 2007 then you must install it on any PC will use the application. Please let me know the best way, tools to do that. Thank You
Basically, interop is pretty much your only real way - but using Word as a storage medium is the real problem! There are various libraries that claim to do it - Google found this which lists a few: Reading doc and docx files using C# without having MS Office installed on server - Stack Overflow[^] - but I've not tested any. Personally, I'd look for a better file format - there is no guarantee that what you read today will stay the same format tomorrow if MS decide to "add features".
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
Hi, We have a C# windows forms application and I need to work with MS Word files to replace some text, table rows content, or add a new rows to an existed table, we need to know the best way. I tried using Microsoft.Office.Interop.Word but this way may be old and must use the same office on the all pc's you install the application on it, if you use the MS Office 2007 then you must install it on any PC will use the application. Please let me know the best way, tools to do that. Thank You
If you can use the newer Office formats, you can use the OpenXML SDK to work with the files without having Office installed.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak -
Hi, We have a C# windows forms application and I need to work with MS Word files to replace some text, table rows content, or add a new rows to an existed table, we need to know the best way. I tried using Microsoft.Office.Interop.Word but this way may be old and must use the same office on the all pc's you install the application on it, if you use the MS Office 2007 then you must install it on any PC will use the application. Please let me know the best way, tools to do that. Thank You
Interop is the only real method of updating Word. We had to make sure ALL users were on EXACTLY the same version of Word to use the application. It was updating legal documents that had to read exactly correctly and turned out to be one of the most painful operations I have ever had to do. If you cannot control the version of Word on all clients then you have a serious problem.
Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP
-
Hi, We have a C# windows forms application and I need to work with MS Word files to replace some text, table rows content, or add a new rows to an existed table, we need to know the best way. I tried using Microsoft.Office.Interop.Word but this way may be old and must use the same office on the all pc's you install the application on it, if you use the MS Office 2007 then you must install it on any PC will use the application. Please let me know the best way, tools to do that. Thank You
Check out NPOI [GitHub - dotnetcore/NPOI: A .NET library for reading and writing Microsoft Office binary and OOXML file formats.](https://github.com/dotnetcore/NPOI) I've used it a lot for Excel .xlsx files and it's always got the job done. They give you sample code that cover most common scenarios.
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP