InsertFile text w/out final Enter

E

Ed

I want to insert the text of a document into an existing (formatted)
paragraph. If I use:

Selection.InsertFile filename:="MyDoc.doc"

then the final 'Enter' of mydoc.doc gets inserted, and that destroys (can't
think of a better word) the formatting of the original paragraph.

Is there any way to pick up almost all of the mydoc.doc (minus the paragraph
marker) so as to preserve the formatting of the paragraph into which the
file is inserted?

Thanks,
Ed
 
H

Helmut Weber

Hi Ed,

if you want just the text,
without the paragraph mark
and without formatting, which
may cause trouble, too:

Dim DocImp As Document
Dim s As String
Set DocImp = Documents.Open("c:\test\insert.doc")
s = DocImp.Range.Text
s = Left(s, Len(s) - 1)
DocImp.Close
Selection.InsertAfter s

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top