>Hello,
>
>I have a problem with OLE automation to Word. I have an existing .dot file with unknown number of bookmarks. I try to find out the names of the bookmarks and replace them with the apropriate data. Behind the bookmarks should be the variables (identical with the fields in in my VFP table) and expressions combining these variables. It is functioning well with the single variables. But I can not find out the content of a bookmark where there is an expression. Can somebody help me further? I would appreciate any help - I am quite new with OLE.
>
>Milos Klas
Hi Milos,
There is a bookmarks and variables collection. To set all variables to field contents (var names match with fields as you said) :
cMyTable = "mytablename"
oWord = createobject("word.application")
with oWord.activedocument
for ix=1 to fcount(cMyTable)
.variables(field(ix,cMyTable)).value = eval(field(ix,cMyTable))
endfor
endwith
And similarly bookmarks collection can be controlled as :
cMyTable = "mytablename"
oWord = createobject("word.application")
with oWord.activedocument
for ix=1 to fcount(cMyTable)
if .bookmarks.exists(field(ix,cMyTable))
.bookmarks(field(ix,cMyTable)).select
oWord.selection.insertafter(eval(field(ix,cMyTable)))
endif
endfor
endwith
Cetin