How to save a copy of Word document with VBA

The steps for the VBA code are currently

1. Get the current word document as object
2. Save the document in a special folder
3. Give this path to a database so that the database can upload the file.
4. Ultimately delete the copy.

I am just using "myDoc.SaveAs CurrentProject.Path & "\Temp\" & str_Save_Name & ".rtf", wdFormatRTF"

At the end of this procedure the currently open document then has this path as its saved path, maybe the user had it saved somewhere else.

What should I do here?
Can I somehow take a copy of an open Word doc and save that without intefereing with the current document?
Or can I reliably just get the current path of the word document (without saving it at all) and use that path to upload?
LVL 20
Who is Participating?
geneusConnect With a Mentor Commented:
Below is some Standard Code that I use to make a Copy of a Document in the Current Directory in order to modify the copied document and keep the original intact.

To get the Current Path of a Document:
MsgBox ActiveDocument.Path

To get the Full Document Name and Path:
MsgBox ActiveDocument.Path & Application.PathSeparator & _
'*Step #1:  Preserve original document by making a copy of the document and working with the copy.*
'Get the Current Document name
varOriginalDoc = ActiveDocument.Name
'Set the New Document Name
If Right(varOriginalDoc, 4) = ".doc" Then
varStringSelection = Len(varOriginalDoc) - 4
varNewDoc = Left(varOriginalDoc, varStringSelection) & "_Copy.doc"
ElseIf Right(varOriginalDoc, 4) = "docx" Then
varStringSelection = Len(varOriginalDoc) - 5
varNewDoc = Left(varOriginalDoc, varStringSelection) & "_Copy.docx"
End If
'Create and Save the new Document copy
Documents.Add Template:="Normal", NewTemplate:=False, DocumentType:=0
ActiveDocument.SaveAs FileName:=varNewDoc, FileFormat:= _
        wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _
        True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
        False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
'Switch to the Original Document
'Select the entire Document and Copy the Contents
Selection.HomeKey Unit:=wdStory
'Switch to the new Document

Open in new window

darbid73Author Commented:
Hey thanks for the great code - One thing I am concerned about is that the OriginalDoc could have any type of things on it, tables, pictures, special formating really anything.

In your experience is a Selection.Copy and I imagine (but you did not put it in the code) a Selection.Paste reliable?

I am not that experienced in Word - so please excuse the dumb what if questions - but your new document will be based on - what if they used another template for the original document, will a copy and paste work ok here?
darbid73Author Commented:
testing does not seem to show any problems with the copy/paste method.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.