Copy RTF content and save new doc to specific directory

Q

QB

I need to automate

Opening a word document (shell file used as a template)
Copy the content of a rft file into the word doc
Save As the doc to a given directory with a specific name

How would I approach achieving this?

Thank you,

QB
 
P

Pesach Shelnitz

The following code opens the specified Word document.

Dim doc As Document
Set doc = Documents.Open("C:\MyFolder\MyFile.doc")

The following code inserts the specified RTF file into file opened.

Selection.InsertFile FileName:="C:\MyFolder\content.rtf", _
ConfirmConversions:=False

By default, Selection represents the location of the cursor when the first
file is opened. You can add code before calling InsertFile to move the cursor
or expand the selection, or you can use a Range object, such as a bookmark,
to define the place where the contents of the RTF file will be inserted.

The following code saves the file with the specified name in the specified
folder, and then closes the file.

doc.SaveAs FileName:="C:\MyOtherFolder\MyNewFile.doc"
doc.Close
 

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