Hi Cetin,
Thanks for the code. I'm almost there... Would you store the names of the fields in an array or just step through the table names then check to see if the bookmark exists in the document? or step through the bookmarks and check to see if a table.field exists? Thinking out loud...
Thanks
>>If I have a listbox of Word templates and the user selects one. There may be anywhere from 1 to 30 bookmarks. I know that I can use the Bookmarks() collection to step through each bookmark in the document. What is the best algrothim to see if a match is there with one of my field names?
>>
>>loDoc = oWord.Documents.open(lcFullPathDocument)
>>lnBookmarkCount = loDoc.Bookmarks.count
>>
>>** Use a for loop to flip through them all.
>>for lnI = 1 to lnBookmarkCount
>> lcBookMarkname = oDoc.bookmarks[lnI].name
>> lcNewValue = FindName(lcBookMarkname)
>> oDoc.Bookmarks[lnI].range.text = lcNewValue
>>endfor
>>
>>What would be a good method to find the names?
>>
>>Thanks
>
>
with oWord.ActiveDocument
>if .Bookmarks.Exists(cBookmarkName)
> .Bookmarks(cBookmarkName).Range.Text = 'blahblah'
>endif
>Cetin