Hi -
I have a form letter that uses an Access query for its data source. This letter will be produced several times a week. Once the letter has merged to a new document, I want the end document to save and name itself automatically. For instance, I would want a letter produced today to be named "20020618.doc". I don't want to go the InputBox route due to user errors.
I know this is wrong, but here's what I have so far:
Sub welcomeletter()
Dim name
ChangeFileOpenDirectory _
"\\Case Data\\WelcomeLetters\"
Documents.Open filename:="""welcomeletter.DOC""", ConfirmConversions _
:=False, ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
filedate = Date
filename = filedate + ".doc"
ChangeFileOpenDirectory _
"\\Case Data\WelcomeLetters\Complete\"
ActiveDocument.saveas filename:=filename, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveDocument.Close
ActiveDocument.Close
End Sub
Can anyone help?
Thanks,
Susan
I have a form letter that uses an Access query for its data source. This letter will be produced several times a week. Once the letter has merged to a new document, I want the end document to save and name itself automatically. For instance, I would want a letter produced today to be named "20020618.doc". I don't want to go the InputBox route due to user errors.
I know this is wrong, but here's what I have so far:
Sub welcomeletter()
Dim name
ChangeFileOpenDirectory _
"\\Case Data\\WelcomeLetters\"
Documents.Open filename:="""welcomeletter.DOC""", ConfirmConversions _
:=False, ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
filedate = Date
filename = filedate + ".doc"
ChangeFileOpenDirectory _
"\\Case Data\WelcomeLetters\Complete\"
ActiveDocument.saveas filename:=filename, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveDocument.Close
ActiveDocument.Close
End Sub
Can anyone help?
Thanks,
Susan