Microsoft.Office.Interop.Word.Document not maintaining tab indents at Paragraph First Lines

Justin Smith 0 Reputation points


I have been struggling with this problem. I have a simple word document with paragraphs indented at the first line with a number of tab characters. Some paragraphs have 1 tab, some have 2, some 3, etc.

I am taking this text to Autodesk's Revit but before I get there, my Paragraph objects lose the tab at the beginning of the first line. If I can just count them, I will add them back but I cannot figure out how to do that.

If my word document is written like this:

First line text

      Second line text (with one tab)

               Third line text (with two tabs)

I get:

First line text

Second line text

Third line text

Microsoft.Office.Interop.Word.Document wdoc = wapp.Documents.Open(openFileDialog1.FileName, ReadOnly: true, Visible: false);


Debug.Print("TOTAL DOCUMENT:::::::::::::::     " + wdoc.Content.Text); //The tabs do not display here although space characters do.

foreach (Microsoft.Office.Interop.Word.Paragraph p in wdoc.Paragraphs) {
Debug.Print("THIS IS THE MAIN P:  " + p.Range.Text);
A family of Microsoft word processing software products for creating web, email, and print documents.
501 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
9,469 questions
{count} votes