Macro to Call Template and Save Doc

F

Freckles

I need to call a template from a macro then save it as a Word Document with a
name that changes based on the date.
--------------------------------------------------------------
This part works --
Sub Get_Template()
'
' Get_Template Macro
' Macro recorded 10/20/2008 by Deb Koplen
'
ChangeFileOpenDirectory "E:\ABS SPA\"
Documents.Open FileName:="""####_DSR Government Education
Segment.dot""", _
ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
wdOpenFormatAuto, XMLTransform:=""

Now I want to save it as a Word document in a different directory with the
current MMDD as part of the name of the document. This part of my macro does
not work:

ChangeFileOpenDirectory _
"W:\GOVERNMENT & EDUCATION\Daily Sales Reporting SPA\ATTACHMENTS\"
ActiveDocument.SaveAs FileName:= _
"Format(Now(), mmdd)" & "_DSR Government Education Segment.doc",
FileFormat:=wdFormatDocument _
, LockComments:=False, Password:="", AddToRecentFiles:=True, _
WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _
False
 
F

Freckles

OK, I have now got the second part to save to the correct directory so I just
need to know how to make it us a prefix of the current month day as mmdd
Example: 1021_DSR Government Education Segment.do
----------------------------------------------------------------------------------
ActiveDocument.SaveAs FileName:="W:\GOVERNMENT & EDUCATION\Daily Sales
Reporting SPA\ATTACHMENTS\DSR Government Education Segment.doc",
FileFormat:=wdFormatDocument _
, LockComments:=False, Password:="", AddToRecentFiles:=True, _
WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _
 
G

Graham Mayor

Sub Get_Template()
Dim sDocPath As String
Dim dDoc As Document
sDocPath = "W:\GOVERNMENT & EDUCATION\Daily Sales Reporting
SPA\ATTACHMENTS\"
Set dDoc = Documents.Add("E:\ABS SPA\####_DSR Government Education
Segment.dot")
dDoc.SaveAs sDocPath & format(Now, "MMdd") & "_DSR Government Education
Segment.doc"
End Sub

should do the trick

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
F

Freckles

Few too many quotation marks but worked perfectly after changing to read

Dim sDocPath As String
Dim dDoc As Document
sDocPath = "W:\GOVERNMENT & EDUCATION\Daily Sales Reporting SPA\ATTACHMENTS\"
Set dDoc = Documents.Add("E:\ABS SPA\####_DSR Government Education
Segment.dot ")
dDoc.SaveAs sDocPath & Format(Now, "MMdd") & "_DSR Government Education
Segment.doc "
--------------------------------------------------

THANKS MUCH

Graham Mayor said:
Sub Get_Template()
Dim sDocPath As String
Dim dDoc As Document
sDocPath = "W:\GOVERNMENT & EDUCATION\Daily Sales Reporting
SPA\ATTACHMENTS\"
Set dDoc = Documents.Add("E:\ABS SPA\####_DSR Government Education
Segment.dot")
dDoc.SaveAs sDocPath & format(Now, "MMdd") & "_DSR Government Education
Segment.doc"
End Sub

should do the trick

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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