I'm trying to do the VB.NET --> Microsoft word automation thing. I have some hidden fields (index code fields) within the word document. I want to iterate through the fields and pull out the text for later processing:
Dim myfield as Word.Field
Dim myfieldstring As String
For Each myfield In .Selection.Fields
myfield.Select()
myfieldstring = myfield.Data.toString
MsgBox("This hidden field contains: " & myfieldstring)
Next
....
However, I get a run-time error on the line:
myfieldstring = myfield.Data.toString
Specific error: "The selection does not start in a field."
Does anybody know what I'm doing wrong? I can't figure it out. Thanks you,
Bryan
Dim myfield as Word.Field
Dim myfieldstring As String
For Each myfield In .Selection.Fields
myfield.Select()
myfieldstring = myfield.Data.toString
MsgBox("This hidden field contains: " & myfieldstring)
Next
....
However, I get a run-time error on the line:
myfieldstring = myfield.Data.toString
Specific error: "The selection does not start in a field."
Does anybody know what I'm doing wrong? I can't figure it out. Thanks you,
Bryan