Question Unable to set line spacing in Word doc programatically

tpabobby

New member
Joined
Jul 2, 2017
Messages
1
Programming Experience
Beginner
I am new to c#. I'm trying to create a Word document programatically with list level. I have a rudimentary understanding of classes, methods, and namespaces. I can't get any formatting whatsoever in the code below to apply (the linespacing rules or tab indent). I'm trying to remove the 8 lines after each line in Word and set to 0.

Microsoft.Office.Interop.Word.Paragraph para1 = document.Content.Paragraphs.Add(ref missing);
para1
.Range.ParagraphFormat.LineSpacingRule=Microsoft.Office.Interop.Word.WdLineSpacing.wdLineSpaceExactly;
para1
.Range.ParagraphFormat.SpaceAfter=0.0f;
para1
.Range.Paragraphs.LineSpacingRule=Microsoft.Office.Interop.Word.WdLineSpacing.wdLineSpaceExactly;
para1
.Range.Paragraphs.SpaceAfter=0.0f;
para1
.Range.ParagraphFormat.TabHangingIndent(1);
para1
.Range.Text="1. TESTING"+Environment.NewLine+"a. Line1"+Environment.NewLine+"b. Line2";
para1
.Range.InsertParagraphAfter();
 

Latest posts

Back
Top Bottom