Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

InsertFile text w/out final Enter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ed - 16 Mar 2005 05:21 GMT
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
Helmut Weber - 16 Mar 2005 10:52 GMT
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
Ed - 16 Mar 2005 12:16 GMT
That does the trick. Thanks. -Ed
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.