Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
Word.Document doc = Globals.ThisAddIn.Application.ActiveDocument;

doc.SaveAs2(FileName: Path.GetDirectoryName(doc.FullName) + Path.GetFileNameWithoutExtension(doc.Name) + ".txt",FileFormat:Word.WdSaveFormat.wdFormatText);



when convert the word file to txt file it shows the exception "COM EXCEPTION was unhandled by user code" command failed how to cure it
Posted

This is a chance for debugging, see The Documentation[^].
 
Share this answer
 
You could wrap the call in a try-catch block. But I do not recommend to swallow (i.e. ignore) the execption - better get the COM exception code, and its meaning with Word Interop, to eventually get rid of the reason of failure.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900