[dba-Tech] Determine current position in Word

Bryan Carbonnell carbonnb at gmail.com
Tue Aug 23 11:53:44 CDT 2005


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


-- 
Bryan Carbonnell - carbonnb at gmail.com
Life's journey is not to arrive at the grave safely in a well
preserved body, but rather to skid in sideways, totally worn out,
shouting "What a great ride!"



More information about the dba-Tech mailing list