PDA

View Full Version : Find first field question



bwwhite
09-29-2011, 06:24 AM
I am creating a mail merge and want each result saved as a separate Word document. I want to name each document using the result of the first field in each result.

I have found code to count fields and modify the properties of each field, but how do I just find the first field? Is it just brute force like the attached code, or is there an easier way?

Thanks!

Bruce


i = 0
For each oFld in myRange.Fields
If i = 0 then
myText = oFld.Result
Endif
i = i + 1
Next

macropod
10-05-2011, 06:44 PM
Hi Bruce,

After executing the mailmerge, there'll be no mailmerge fields in the output document, so any code you use needs to run the mailmerge process on a record-by-record basis. A web search will turn up a number of solutions for doing this kind of thing.