How do I read the value of a checkbox in a word (*.doc) file in VB.net using a range object?
This is what I have so far:
Dim app As New Word.Application
Dim doc As Document
doc = app.Documents.Open("C:\myDoc.doc")
dim chkBox as Bookmark
chkBox = doc.Bookmarks("MyCheckbox")
Dim rng as Range
rng = chkBox.Range
where “MyCheckbox” is the bookmark of the checkbox in the word document.
Any particular reason you’re not reading the value of the checkbox using the name of the checkbox itself?
If the range defined by your bookmark contains a checkbox, then, depending upon how the checkbox is inserted, it will be found in either the
InlineShapescollection (if checkbox inserted inline with the text) or theShapescollection (if inserted as a floating object.)You would then need to iterate through the collection of Shapes or InlineShapes looking for the checkbox in question.
Iterating through controls in InlineShapes collection
This ought to get you closer, but if the name of the checkbox is predictable, it is better to address it directly by name.