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);
                    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?  
Who is Participating?
Nebulus_Connect With a Mentor Commented:
maybe instead of for is easy with foreach (of course for collections):

foreach(Word.FormField ffObj in aDoc.FormFields) {
  // some work with ffObj
menreeqAuthor Commented:
That did it, thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.