Can someone please explain for me what the following code means? Basically i know the code is supposed to run through the document, look for fields (in a form) then insert a bookmark name (bookmark#1 thru...whatever). I just don't know what the code (words) mean. I'm interested in modifying this for my own purposes. Thanks.


[VBA]Option Explicit
Private Sub s_FillinBookmarks()
Dim i As Integer
Dim aBookmark As Bookmark
Dim amarks() As String

If ActiveDocument.Bookmarks.Count >= 1 Then
ReDim amarks(ActiveDocument.Bookmarks.Count - 1) As String
i = 0
For Each aBookmark In ActiveDocument.Bookmarks
amarks(i) = aBookmark.Name
If Mid(amarks(i), 1, 4) = "Text" Then
ActiveDocument.FormFields(amarks(i)).Result = _
CStr(Mid(amarks(i), 5, Len(amarks(i)) - 4))
ElseIf Mid(amarks(i), 1, 5) = "Check" Then
ActiveDocument.FormFields(amarks(i)).CheckBox.Value = True
ActiveDocument.Bookmarks(amarks(i)).Select
Selection.InsertAfter (CStr(Mid(amarks(i), 6, Len(amarks(i)) - 5)))
End If
i = i + 1
Next aBookmark
End If

End Sub[/VBA]