Unnikrishnan
Unnikrishnan

Reputation: 563

How to hide the word textbox border?

Using C# I have succeeded in opening a word document and writing text to it. Now I want to insert a text box into the word document also by using c# code and I succeeded with the code I found elsewhere on internet. This was the code:-

Microsoft.Office.Interop.Word.Shape textbox = oDoc.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 70, 30); //MsoTextOrientation.msoTextOrientationVertical
textbox.TextFrame.TextRange.Text = "Date";

It worked fine. But my problem, I would like to hide the default border of the text box with c# code. I tried searching for it but could not find one.

Could anyone help me? Thanks in Advance Unnikrishnan, India

Upvotes: 2

Views: 3099

Answers (1)

Unnikrishnan
Unnikrishnan

Reputation: 563

Microsoft.Office.Interop.Word.Shape textbox = oDoc.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 70, 30);`         
textbox.TextFrame.TextRange.Text = dateTimePicker1.Value.toShortDateString();`//this will insert a ms word textbox on ms word document.
textbox.Line.Visible = MsoTriState.msoFalse;` // this will hide the border or line of textbox.
textbox.TextFrame.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;` //this will align the text within the textbox to rthe right side of the textbox.

//In this oDoc is the document added. Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application(); Microsoft.Office.Interop.Word.Document oDoc = new Microsoft.Office.Interop.Word.Document();

//I tried it with visual c# express 2010 and word 2007 and 2010 on different computers with operating system of Windows XP and Windows 7.

Upvotes: 2

Related Questions