Shamil Salakhetdinov
shamil at smsconsulting.spb.ru
Thu Dec 2 11:54:50 CST 2010
Hi Rocky -- You can enumerate bookmarks of an MS Word document the following way: Dim bmk As Word.Bookmark For Each bmk In Application.ActiveDocument.Bookmarks Debug.Print bmk.Name Next bmk Thank you. -- Shamil -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin Sent: 2 ??????? 2010 ?. 20:11 To: 'Access Developers discussion and problem solving' Subject: [AccessD] Merging data to Word using Bookmarks 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/> -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com