Text Box

A

Alan Wang

Hi all,

I am just wondering if I can programmatically insert text box into word
document.

Alan
 
R

Randall Arnold

Yes you can. I don't know the syntax offhand but I'm sure a google search
can turn it up. Or you can start recording a macro in Word, insert a text
box, close your macro and check the code to see how you can use it.

Randall Arnold
 
B

Bill

Hi Alan,

Instructions in C# for inserting adding three lines of text, putting
a textbox at the start of the second line (size specified in the AddTextBox
call),
adding some text to the box, and changing the layout to make the box inline
with the text are:

object opt = Type.Missing;
Word.Shape shape;
word.Selection.Text = "One\r\nTwo\r\nThree\r\n";
word.Selection.SetRange(5, 5);
object sel = word.Selection;
shape =
doc.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal,
5.0f, 10.0f, 250.0f, 100.0f, ref sel);
shape.TextFrame.TextRange.Text = "Put this in the box";
shape.WrapFormat.Type = Word.WdWrapType.wdWrapInline;

I can send you the sample program if you like

Cheers
Bill
 
A

Alan Wang

Bill:

I would like to see your code and also I would like to insert image inside
the text box. I am wondering if you have the sample code for that.

Thanks in advanced

Alan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top