[AccessD] Merging data to Word using Bookmarks

Rocky Smolin rockysmolin at bchacc.com
Thu Dec 2 11:11:28 CST 2010


Dear List:
 
This is a legal app - they wanted to be able to merge data from the app into
many different legal forms.  I used bookmarks in the legal form where the
bookmark is the name of the field in the table.  
 
Set qdf = db.QueryDefs("qryAllLoanFields")
mobjWord.WordBasic.FileOpen Name:="" & Me.txtmergeDocument & ""
 
On Error GoTo IsIt5102:
 
For Each fld In qdf.Fields
    strFieldName = fld.Name
    fExists = True
    mobjWord.Selection.GoTo What:=wdGoToBookmark, Name:=strFieldName
    If fExists = True Then
               mobjWord.WordBasic.Insert "" & Forms!frmLoans(fld.Name) & ""
    End If
Next fld
 
mobjWord.WordBasic.AppShow
 
Set mobjWord = Nothing
Set qdf = Nothing
Set db = Nothing

This worked OK until they required one field to appear more than once in a
document and Word does not allow duplicate bookmrk names.
 
So I'm looking for a workaround.  If I could cycle through the bookmarks in
the doc I could have them append somethinf like '_DUPx' to the bookmark name
and still find the data field by stripping off the '_DUPx'.  But I'm
uncertain how to cycle through bookmarks in a word doc like you do all the
fields in a table.
 
Does anybody have any slick ideas for a different approach to this problem?
 
My current backup plan is to just pur the duplicate fields into he table,
maintiain them transparently to the user - then insert those names as unique
bookmarks.
 
MTIA
 

Rocky Smolin

Beach Access Software

858-259-4334

Skype: rocky.smolin

www.e-z-mrp.com <http://www.e-z-mrp.com/> 

www.bchacc.com <http://www.bchacc.com/> 

 

 




More information about the AccessD mailing list