Create doc file. Microsoft.Office.Interop.Word.Application

Asked

Viewed 88 times

0

I’m with a legacy application, in Visual Studio, which generates files .doc, using Microsoft.Office.Interop.Word.Application.

The application adds lines, spelling a few words, but sometimes the text gets truncated.

I’ve searched for ascii code and so far found nothing.

Thank you,

  • you could exemplify with your code, so we can view better

  • 1

    preferably the part of the code where it reads the information (from where it searches) and the part of the writing of the file.

  • Follows the code:

  • Microsoft.Office.Interop.Word.Application wordapp = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document worddoc = new Microsoft.Office.Interop.Word.Document();

  • nl string = System.Environment.Newline; worddoc = wordapp.Documents.Add(); Microsoft.Office.Interop.Word.Range Rng = worddoc. Paragraphs[1]. Range;
wordapp.Application.Selection.Font.Size = 10;
wordapp.Application.Selection.Font.Name = "Courier New";
wordapp.Application.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft; wordapp.Application.Selection.ParagraphFormat.Spaceafter = 0;

  • Stringbuilder strCabecalho = new Stringbuilder(); strCabecalho.Append("----------------------------------------------------------------------" + nl);
 strCabecalho.Append(" P R O T O C O L O " + "( " + pesqPge.nmeArchive + " )"); //Inserts publication data wordapp.Application.Selection.Typetext(strFormatacao.Tostring()); //Inserts a page break

  • It seems that the problem occurs in this: wordapp.Application.Selection.Typetext(strFormatacao.Tostring());

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.