Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

inserting a Word document 1

Status
Not open for further replies.

TomG1

Programmer
Apr 12, 2001
25
BE
Hi all,

I know how to open a document with VBA-code
Documents.add "document"

Now, how can I insert the document in existing text, without first opening the document and then copy and paste it? This should be done with VBA-code

thx
 
Tom, the best thing to do for situations like this is to record a dummy macro of what you want to do and then copy the code that it creates (perhaps with minor edits)

For example, I recorded a macro of using the Insert Menu and selected the File option and this is the code that it produced:

Code:
Selection.InsertFile FileName:="doc2insert.doc", Range:="", ConfirmConversions:=False, Link:=False, Attachment:=False
[\code]

Try this code out. The Range option is for a pre-defined bookmark (in case you do not want the whole document).  The Link option will set a link to the file (rather than embedding a copy).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top