469,332 Members | 6,969 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,332 developers. It's quick & easy.

Using VB .NET to iterate through a Fields Collection within a Microsoft Word Document ?

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
Nov 21 '05 #1
0 2714

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Benjamin Piorczig | last post: by
3 posts views Thread by Adam Faulkner via DotNetMonster.com | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by haryvincent176 | last post: by
reply views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.