Hi Barbara,
I ended up using a combination of both your suggestions and Cetin's.
ThisForm.oWord = CreateObject("Word.Application")
WITH Thisform.oWord
oDoc = .Documents.Open(lcTemplate)
.ActiveDocument.SaveAs("Temp.doc")
WITH Thisform.oWord.ActiveDocument
FOR nField = 1 TO FCOUNT("tmpQuote")
IF .Bookmarks.Exists(FIELD(nField))
.FormFields(FIELD(nField)).Result = ALLTRIM(TRANSFORM(EVALUATE(FIELD(nField))))
ENDIF
ENDFOR
ENDWITH
.Visible = .T.
.WindowState = 0
WAIT WINDOW "Press any Key to Continue"
ENDWITH
I added the wait wind to stop processing until the word object is closed.
Sometimes I have several instances of WinWord running in the taskmanager. Is there a way to detect this?
Thanks
>John,
>I used Formfields, and went through them with the
>FOR n = 1 to oWord.activedocument.formfields.count
> do case
> case oWord.activedocument.formfields.result = "Address1"
> do stuff
> case oWord.activedocument.formfields.result = "Address1"
> do other stuff
> endcase
>NEXT
>This picked up the Default text, not the bookmark, which I did deliberately - I was producing contracts where the same field information may be inserted a lot of times. When I needed the actual bookmark I used oWord.activedocument.formfields.name
>
>The Do Case loop could get pretty long, but it ran pretty fast. It did take longer when I needed to build tables 'on the fly' for data of unknown record count. However the clients said they really liked having the 'Now entering Contract Name' 'Now building table of receivables' and other messages as it ran. They really didn't care if it took 2-3 minutes (for a 5 page contract) as long as they knew it was still working.
>
>HTH
>Barbara
>
>
>>Hi Barbara,
>>
>>Do you store the names in an array to search for them?
>>
>>Thanks
>>
>>>Someone else may come up with a better way, but I do essentially the same thing and add a Wait Window that shows "1 of 30", "2 of 30" etc. User feels that things are flying along while he waits. Since I've had upwards of 150 items PLUS 3-5 tables it's important for the users to feel that they know what's happening.
>>>