How to access legacy forms checkboxes and ActiveX checkboxes in Word using C#!

Apparently, doing this simple task is not well documented. None of my searches lead to anything useful, so here is what I wrote for how to handle the search for all checkboxes in a word document then set them all to false. Obviously, you can use this to get values, launch rockets, whatever it is you want to do.

[csharp]
//go through legacy fields.
foreach (FormField c in vstoDoc.FormFields)
{
try
{
if (c.Type == WdFieldType.wdFieldFormCheckBox)
{
if (c.CheckBox.Value)
c.CheckBox.Value = false;
}
}
catch { }
}

//go through the activex fields.
foreach(Field f in vstoDoc.Fields)
{
if (f.Type == WdFieldType.wdFieldOCX)
{
try
{
if (f.OLEFormat != null)
{
if(f.OLEFormat.ProgID.ToLowerInvariant().Contains("checkbox"))
{
if(f.OLEFormat.Object.Value)
f.OLEFormat.Object.Value = false;
}
}
}
catch { }
}

}
[/csharp]

I am sure you figured out my variable vstoDoc is the document. If not, well, McDonalds always need a new fry cook.

Happy Coding!