Bryan Carbonnell
carbonnb at gmail.com
Tue Aug 23 11:50:29 CDT 2005
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 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 To insert a file at a specific you don't need the character position. You can do it like this: dim rng as Range set rng = Selection.Range rng.InsertFile ("C:\autoexec.bat") set rng = Nothing HTH, -- 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!"