Hi Guys,
Am wanting to iterate through a set of Mailmerge Fields within a MS-Word
document using VB .NET. Here's a fragment of code that (should) do this!
Dim WordDoc As Word.Document =
WordApp.Documents.Add("Test.doc")
WordDoc.Activate()
Dim Field As Word.Field
Dim C As Integer = 1
While C <= WordDoc.Fields.Count
Field = WordDoc.Fields.Item(C)
Field.Select()
C = C + 1
End While
However, I've noticed that not all the fields are picked up, suspect it's
this line that's the problem...
Field = WordDoc.Fields.Item(C)
Although I don't understand why. In the debugger, C runs through as a
sequence, i.e. 1,2,3,4,5,6 etc
'For Each Field In Word.Fields' doesn't seem to work.
Any help appreciated.
Regards,
Shaun