How to move a range variable to the end of an inserted file after using [range].InsertFile

Article contributed by Dave Rado and Will Rickards

When you use MyRange.InsertFile, the range ends up collapsed at the start of the inserted text rather than at the end!

Workaround 1

Use Selection.InsertFile instead (preceded by MyRange.Select if necessary). This leaves the selection collapsed at the end of the inserted text rather than at the start.

Workaround 2

Dim rngStart As Range
Dim rngEnd As Range

Set rngStart = whatever (where you want the file inserted)
rngStart.Collapse direction:=wdCollapseStart
Set rngEnd = rngStart.Duplicate
rngEnd.InsertParagraph
rngStart.InsertFile "C:\Temp\test.doc"
rngEnd.Characters.Last.Delete

Nuts and sledgehammers come to mind, but that works. However, the selection-based workaround is faster as well as needing less code, so you may wish to stick to using Selection.InsertFile – unless you have made Word invisible, in which case it is (apparently) usually safest to avoid using selections completely; so in that situation. Workaround 2 may work better for you.

This is definitely a feature of Ranges worth contacting http://support.microsoft.com/contactus/ about!