?
Solved

Accessing form.fields in MS Word

Posted on 2003-03-12
2
Medium Priority
?
203 Views
Last Modified: 2010-04-15
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?  
0
Comment
Question by:menreeq
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
Nebulus_ earned 200 total points
ID: 8126114
maybe instead of for is easy with foreach (of course for collections):

foreach(Word.FormField ffObj in aDoc.FormFields) {
  MessageBox.Show(ffObj.ToString());
  // some work with ffObj
}
0
 

Author Comment

by:menreeq
ID: 8138495
That did it, thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question