Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Inserting A Document Into A Specific Location of Current Document

1 view
Skip to first unread message

bob...@hotmail.com

unread,
Jul 29, 2007, 1:26:32 AM7/29/07
to
I am a VBA/Access developer with many years of experience programming
in VBA. I typically program from Access and access other apps (Excel)
via Access. I currently use Access/Word 2002.

The situation:
I use a template document to read in data from Access (mail merge),
which is working fine (Access Cookbook, O'Reilly, chapter 12.4, pages
563-567). Additionally, if a document is type 'X', then I have a need
to insert a document that contains a few lines of formatted text w/
bullets. Else, do not insert the document. IThe insert should occur
after paragraph 17 (which is not the end of the document), but do not
know how to move the cursor to that position to do the insert. I do
know how to insert the required file:

' Insert text after 17th paragraph return
Dim aDoc As Document
Dim myRange As Range
Set aDoc = ActiveDocument
Set myRange = aDoc.Range(aDoc.Paragraphs(17).Range.Start, _
aDoc.Paragraphs(17).Range.End)
myRange.InsertFile ("S:\CarGay testing\CarGay testing
\Insert.doc")

When I run the code, it inserts the file at the top of the document,
not after paragraph 17.

Thanks for looking.
Bob

Greg Maxey

unread,
Aug 26, 2007, 8:00:19 PM8/26/07
to
Sub Test()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Paragraphs(17).Range
oRng.Collapse wdCollapseStart
oRng.InsertFile "C:\Test.Docm"
End Sub
0 new messages