#1
|
|||
|
|||
Can no longer read and save WORD documents as TXT files
Hello, after getting a new Windows7 work PC, i can no longer programatically read WORD documents from a C# program and SAVE those WORD documents as new TXT files, but on my previous Windows7 work PC, I was able to read WORD documents and SAVE those WORD documents as new TXT files programatically using C#.
Also, on my new work PC, i don't have ADMIN rights, but i didn't have ADMIN rights on my previous work PC and was able to generate new TXT files from WORD documents programatically. So for now, i'm transferring my WORD documents to my personal Windows8 machine at home and generating the TXT files there and tranferring the TXT files back to my Windows7 work machine. I also checked the WORD option settings on my work PC and didn't see anything in particular that seemed to be blocking the reading and saving of WORD documents to a TXT file format ie: Code:
Microsoft.Office.Interop.Word.Application newApp = new Microsoft.Office.Interop.Word.Application(); object miss = System.Reflection.Missing.Value; object path = pathin; object readOnly = false; Document doc = newApp.Documents.Open(destFile, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss); object format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocument; object nFileName = pathin + "\\" + fileName + ".txt"; object FileFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatText; object oMissing = System.Reflection.Missing.Value; doc.SaveAs(ref nFileName, ref FileFormat, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); doc.Close(); Thanks very much for any ideas! BobK |
#2
|
||||
|
||||
Have you installed your C# software (Visual Studio?) on the new PC? Do other aspects of the code work as expected? Does whatever path 'pathin' refers to exist on the new PC and do you have write permissions to that folder?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thanks Paul how have you been? long time no talk too! Paul you got me thinking about the fact that my new Visual Studio Express setup may not be compatible, so i put in a try catch around that routine and got the following exception:
Exception:Exception:System.MissingMethodException: Method not found: 'System.Type System.Runtime.InteropServices.Marshal.GetTypeFrom CLSID(System.Guid)'. And when i googled it, it mentioned a possible versioning difference, so when i changed the Visual Studio version number back to to 4.0 from 4.5 its now working! And Paul, i just wanted to mention that the reason i'm converting WORD documents to TXT, is mainly to build a cross reference to fields that are in the WORD documents and even though i can't specifically hyperlink to a specific word value location in the document, i can know if a specific word value is in a particular WORD document and when i jump to the beginning of the document, i can then use that bookmark/hyperlink tool you helped me build which is working pretty good now! |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
After Word crash, can no longer save as .docx | mrwednesday | Word | 4 | 10-15-2013 01:21 AM |
mouse no longer works inside word documents? | trob | Word | 0 | 02-01-2012 11:36 AM |
Word documents suddenly and randomly open read only | Jennifer Murphy | Word | 0 | 09-03-2011 10:13 PM |
Read text from word documents using VBA? | maxald | Word VBA | 0 | 08-17-2010 06:51 AM |
Can't save word document in anything but read format | Stuckie | Word | 0 | 01-21-2010 12:46 PM |