c# word automation. How to get or read value from a textbox on a word document

R

RobertK

I am doing some word automation with c#. I need to be able to get
values from textboxes on the word document. Is there any way I could
find all the textbox control on the doc and loop through them?
 
R

RobertK

I am doing some word automation with c#. I need to be able to get
values from textboxes on the word document. Is there any way I could
find all the textbox control on the doc and loop through them?

Forgot to add a little detail. The textbox that I am trying to access
values from c# is a textbox object and was created from the Visual
basic toolbox. Its not a formfield.
 
K

Kristijan Marin

Hi,

Well i'm dealing with almost the same problem..... you should maybe take a
look at Document.Shapes object .....

at least this is the place where a found AddTextBox method ..... and there
is a Count , i'm not sure but maybe this could be it ....

/Kris
 
A

Andrey Dzizenko

Oh... Kris, I see you found AddTextBox =)

That's correct, Robert. Enumerate Document.Shapes and get its property
called Type. It's msoShapeType that will be "msoTextBox" if it's TextBox..

Andrey Dzizenko.
 
R

RobertK

Hi,

Well i'm dealing with almost the same problem..... you should maybe take a
look at Document.Shapes object .....

at least this is the place where a found AddTextBox method ..... and there
is a Count , i'm not sure but maybe this could be it ....

/Kris

Did you ever find the solution? Can you post it for me please?
 
R

RobertK

Heres my solution.

MSForms.TextBox tb =
(MSForms.TextBox)oDoc.InlineShapes[1].OLEFormat.Object;

tb.text will give the value I am looking for.

thanks Andrey and Kristijen
 

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