Jürgen Welz
jwelz at hotmail.com
Fri Feb 10 13:02:40 CST 2006
Ditto on WordBasic I often protect documents for formfields so insertafter doesn't work if you set the bookmark property for a Word textbox field. This lets me set default values in a form. owdDoc.Bookmarks("ProjectName").Select owdApp.Selection.Text = strProjectName where owdDoc is an object variable pointing to a Word.Document and owdApp is an object variable pointing to an instance of Word in which the Document is open. My system sends a collection of data elements from one or more recordsets using a key matching the first portion of the bookmark name up to a delimiter. The balance of the bookmark name determines formatting properties. A second delimited part of the bookmark name allows bookmarks drawing from the same data collection item to write to multiple bookmarks (you can't have more than one bookmark with the same name in a document). This way, the document controls the formatting of the data. In some documents you may want "Wednesday, the 4th day of September) where as other documents are fine with "9/4/2006". Also, if a field, like a person's name appears more than once, "John;", "John;1" and "John;2" can all pull the collecion 'John' item. I iterate the Document's bookmark collection and throw the matching collection item at the bookmark. Generally I use a recordset's field name or alias as the collection key. Ciao Jürgen Welz Edmonton, Alberta jwelz at hotmail.com >From: Bryan Carbonnell <carbonnb at gmail.com> >On 10/02/06, Jim Dettman <jimdettman at earthlink.net> wrote: > > > mobjWord.WordBasic.INSERT > > pelNullToZLS(rstData(avarFields(pelFldAccessField, intJ))) > > >Ick!!! WordBasic!!!! > >John, > >Here is a little chunk that should do it for you: > >Dim doc As Word.Document >Dim rng As Word.Range > >Set rng = doc.Bookmarks("MyBookmarkName").Range > >rng.InsertAfter "This text gets inserted after the bookmark" > >-- >Bryan Carbonnell - carbonnb at gmail.com