Arthur Fuller
artful at rogers.com
Wed Aug 24 10:44:01 CDT 2005
I have tried both methods and I must be doing something wrong because neither method works for me. Here is the exact scenario: I open a template containing numerous bookmarks. I open a recordset and populate the bookmarks with values from the recordset. So far so good. I also write an RTF document containing the rows and columns of the tables that I need (there are two). I know the name of the RTF I just generated. Then I try to apply your code and nothing happens. The tables I must insert occur at a bookmark which is in about the middle of the document. I populate bookmarks before and after said bookmark. All works well. Now, I try your second example code fragment. I had a problem with the line: Set rng = doc.Bookmarks("BookmarkName").Range I changed it to: Set rng = doc.Bookmarks.Item("AdditionalInformationTable") Then it compiled successfully (Access 2003). However, nothing is there in the resulting document where the table should be. All the other bookmarks have been successfully populated, but not the one where I want to plant the table(s). I am obviously doing something wrong. Please tell me what it is. -----Original Message----- From: dba-tech-bounces at databaseadvisors.com [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of Bryan Carbonnell Sent: August 23, 2005 12:54 PM To: Discussion of Hardware and Software issues Subject: Re: [dba-Tech] Determine current position in Word On 23/08/05, Bryan Carbonnell <carbonnb at gmail.com> wrote: > On 22/08/05, Arthur Fuller <artful at rogers.com> wrote: > > Assuming that I go to a particular bookmark in a Word document, how can I > > determine the position of the cursor (as expressed in character-count to > > that point)? I need it because I want to insert a document there... > dim rng as Range > > set rng = Selection.Range > rng.InsertFile ("C:\autoexec.bat") > > set rng = Nothing Another way to do it, if you don't actually want to goto the bookmark, is: Dim doc As Document Dim rng As Range Set doc = ActiveDocument Set rng = doc.Bookmarks("BookmarkName").Range rng.InsertFile ("c:\autoexec.bat") Set rng = Nothing Set doc = Nothing