Jump to content

C# underline help!

Go to solution Solved by fizzlesticks,

Have you tried setting oPara3stSubPara.Range.Font.Underline = Word.WdUnderline.wdUnderlineNone

Hello,

 

I am trying to have a generate a word document.  it has a title, and a paragraph under that.  The title should be underlined, but the paragraph should not.  Seems like i am doing something wrong because when i generate the code, everything is underlined.... is there a different way to under line so that it would cause this? 

 

thank you

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using Word = Microsoft.Office.Interop.Word;using System.Reflection;namespace WindowsFormsApplication20{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private void textBox18_TextChanged(object sender, EventArgs e)        {        }        private void textBox17_TextChanged(object sender, EventArgs e)        {        }        private void textBox16_TextChanged(object sender, EventArgs e)        {        }        private void Form1_Load(object sender, EventArgs e)        {                    }        private void button1_Click(object sender, EventArgs e)        {                                    object oMissing = System.Reflection.Missing.Value;            object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */            //Start Word and create a new document.            Word._Application oWord;            Word._Document oDoc;            oWord = new Word.Application();            oWord.Visible = true;            oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,                ref oMissing, ref oMissing);                        // Title            Word.Paragraph oPara3stSubTitle;            oPara3stSubTitle = oDoc.Content.Paragraphs.Add(ref oMissing);            oPara3stSubTitle.Range.Text = "SubTitle Here";            oPara3stSubTitle.Range.Font.Bold = 0;            oPara3stSubTitle.Range.Font.Underline = Word.WdUnderline.wdUnderlineSingle;            oPara3stSubTitle.FirstLineIndent = 35f;            oPara3stSubTitle.Range.Font.Name = "Arial";            oPara3stSubTitle.Range.Font.Size = 12;            oPara3stSubTitle.Format.SpaceAfter = 15;                oPara3stSubTitle.Range.InsertParagraphAfter();                        //Text Under Title            Word.Paragraph oPara3stSubPara;            oPara3stSubPara = oDoc.Content.Paragraphs.Add(ref oMissing);            oPara3stSubPara.Range.Text = "some text inserted here................................";            oPara3stSubPara.Range.Font.Bold = 0;            oPara3stSubPara.FirstLineIndent = 35f;            oPara3stSubPara.Range.Font.Name = "Arial";            oPara3stSubPara.Range.Font.Size = 12;            oPara3stSubPara.Format.SpaceAfter = 15;            oPara3stSubPara.Range.InsertParagraphAfter();                                }        private void textBox6_TextChanged(object sender, EventArgs e)        {        }        private void textBox19_TextChanged(object sender, EventArgs e)        {                    }    }}
Link to comment
https://linustechtips.com/topic/219042-c-underline-help/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×