Link to home
Start Free TrialLog in
Avatar of menreeq
menreeq

asked on

Accessing form.fields in MS Word

This is my first c# program so i think my question is very basic.  I wrote the folloing program to open a word document and cycle through each field in the form...

          private void button1_Click(object sender, System.EventArgs e)
          {
               if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
               {
                    object fileName = openFileDialog1.FileName;
                    object readOnly = false;
                    object isVisible = true;
                    object missing = System.Reflection.Missing.Value;
                    WordApp.Visible = false;

                    Word.Document aDoc = WordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible);
                    aDoc.Activate();
                    Console.WriteLine(aDoc.FormFields.Count);
                   
                    for(int i=0; i<aDoc.FormFields.Count; i++)
                    {
                         
                    }
               }
          }

I dont know how to cycle through the different fields in the for loop.  What should i put in this loop...or am i on the wrong track?  
ASKER CERTIFIED SOLUTION
Avatar of Nebulus_
Nebulus_

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of menreeq
menreeq

ASKER

That did it, thanks!