PDA

View Full Version : [SOLVED] How to Make Copy of Word Document



ajrob
09-28-2013, 10:04 AM
This should be easy, but I'm stumped. I have a "Master" copy of a .doc file that I don't want to jeopardize changing with VBA, and I don't want to use a template (.dot) because I'm not a big fan of the normal.dot conflicts.

So, the flow of the Excel VBA code is to make a copy of the master word .doc, then to transfer data from Excel to that copy.

Here's a copy of what I tried:


Sub Project_Text()
Dim objWord As Object

Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.Documents.Copy "C:\Master Project Text.doc"
objWord.Documents.Paste "C:\Master Project Text.doc"

Dave
09-28-2013, 06:36 PM
HTH. Dave

Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
'source,destination,save
FSO.CopyFile "C:\Master Project Text.doc", _
"C:\Master Project TextCopy.doc", True
Set FSO = Nothing

ajrob
09-28-2013, 07:45 PM
That's perfect...

Thank you!

shrivallabha
09-28-2013, 09:45 PM
You can do this without FSO as well

FileCopy "C:\Master Project Text.doc", "C:\Master Project TextCopy.doc"

SamT
09-29-2013, 06:48 AM
Option Explicit

Private Sub Document_Open()
'Only runs RenameMe from the Original.

If Me.Name = "Master Project Text.doc" Then ReNameMe
End Sub


Private Sub ReNameMe()
'Creates a copy of and closes the original.
'To modify to the original modify this new copy and save it as "C:\Master Project Text.doc"
' or disable Macros when opening the original.

Me.SaveAs ("C:\Master Project TextCopy.doc")
End Sub

snb
09-29-2013, 12:20 PM
Please read the helpfile of Word's VBEditor.


Sub M_snb()
with CreateObject("Word.Application")
.visible=true
with .documents.add("C:\Master Project Text.doc")
.saveas2 "C:\Master Project Text_002.docx"
end with
end with
end sub


I don't want to use a template (.dot) because I'm not a big fan of the normal.dot conflicts

That never occur. You are fighting a phantom...