Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
object FileName = fileName;
                object utf8 = Encoding.UTF8;
                wrdDoc = wrdApp.Documents.Open(ref FileName, 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, ref oMissing);
                wrdDoc.Activate();
              
                wrdDoc.SaveAs2(ref fileNameProcessed, ref fileFormat, ref missing, ref missing, ref missing, ref missing,
                    ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref utf8,
                    ref missing, ref missing, ref missing, ref missing);
                object saveChanges = WdSaveOptions.wdDoNotSaveChanges;
Posted

According to https://msdn.microsoft.com/en-us/library/office/ff836084.aspx[^] the encoding parameter is the 12th (starting counting with one) but you passed it as 13th:
Quote:
SaveAs2(FileName, FileFormat, LockComments, Password, AddToRecentFiles, WritePassword, ReadOnlyRecommended, EmbedTrueTypeFonts, SaveNativePictureFormat, SaveFormsData, SaveAsAOCELetter, Encoding, InsertLineBreaks, AllowSubstitutions, LineEnding, AddBiDiMarks, CompatibilityMode)
 
Share this answer
 
v2
Further to Jochen's answer, the Encoding parameter expects a code page or character set, but you're trying to pass in an Encoding object.

Word doesn't know about .NET's Encoding type. You need to pass in the CodePage property instead:
C#
object utf8 = Encoding.UTF8.CodePage;
 
Share this answer
 
Comments
Member 10758257 27-Nov-15 0:18am    
Thank You For your reply.Now it is not crashing But Still the html which is generated by this ,having charset=windows-1252 like <meta http-equiv=Content-Type content="text/html; charset=windows-1252"> I want it UTF-8 .how can i get UTF-8 charset also,Can you please help me with that

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