Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Bookmarks
Message
From
08/11/2000 06:42:42
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
07/11/2000 14:11:01
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Miscellaneous
Thread ID:
00438630
Message ID:
00439191
Views:
23
Table names or field names ? Field names I guess :)
Practically would choose the shorter list but instead of not knowing it beforehand and don't want to query I'd choose looping field names and check if a corresponding bookmark exists (not fully tested but after all those OLE work it sounds to me that VBA code is much slower than VFP code and I prefer to loop 250+ in VFP instead of 20 in VBA:)
with oWord.ActiveDocument
  for ix = 1 to fcount()
    if .Bookmarks.Exists(field(ix))
       .Bookmarks(field(ix)).range.Text = transform(eval(field(ix)))
    endif
  endfor
endwith
Cetin

>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform