[dba-Tech] Determine current position in Word

Arthur Fuller artful at rogers.com
Mon Aug 22 11:44:10 CDT 2005


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 objWord as Word.Application
Set objWord = New Word.Application
Dim strTemplateFile As String
strTemplateFile = TEMPLATEPATH	'a constant defining the template
objWord.Documents.Add strTemplateFileo
bjWord.ActiveDocument.GoTo What:="Bookmark",
Which:="AddionalInformationTable"
'next line is where I need help
'To append to the end of the Word document, you can use this:
'InsertPosition = AppWord.ActiveDocument.Characters.Count - 1
'But I don't want the length of the file, 
'I want instead the position of the bookmark
InsertPosition = AppWord.ActiveDocument.   '... What do I write here?
Debug.Print "Insert Position = " & InsertPosition     
AppWord.ActiveDocument.Range(InsertPosition).InsertFile
FileName:="C:\autoexec.bat"   'for example
objWord.Visible = True

Thanks!
Arthur




More information about the dba-Tech mailing list