M
Melissa
I have an excel file template that automated to open from an Access
application that will 1) save the template as a new file with the
current date/time appended to the file name, 2) pull data from an
Access database and format the data into a usable mail merge file, and
3) open the mail merge file in Word. This all works well only I have
two problems with which I need some help.
The first problem is how can I automate the mail merge file to open
with the current Excel file as the datasource for the mail merge?
Right now, I'm cutting and pasting the file path into Word myself.
The second problem is that once the mail merge is done, I close the
Word file and the Excel file. Then I get a message that the Excel
file I just closed file "is now available for editing. Choose Read-
Write to open it for editing." What can I do to prevent this?
Here's the code that currently opens the Word document:
Sub Create_Emails()
Dim appWD As Object
Dim stPath As String
ActiveWorkbook.Save
stPath = "X:\ProdMgt\RRAdmin\Request Proc\Entitlement and Increased
Access Requests\Templates\Request Denied (EIA) TEMPLATE.doc"
Set appWD = CreateObject("Word.Application") appWD.Visible = True
appWD.Documents.Open (stPath)
appWD.ActiveDocument.MailMerge.MainDocumentType = wdEMail Set appWD =
Nothing
End Sub
application that will 1) save the template as a new file with the
current date/time appended to the file name, 2) pull data from an
Access database and format the data into a usable mail merge file, and
3) open the mail merge file in Word. This all works well only I have
two problems with which I need some help.
The first problem is how can I automate the mail merge file to open
with the current Excel file as the datasource for the mail merge?
Right now, I'm cutting and pasting the file path into Word myself.
The second problem is that once the mail merge is done, I close the
Word file and the Excel file. Then I get a message that the Excel
file I just closed file "is now available for editing. Choose Read-
Write to open it for editing." What can I do to prevent this?
Here's the code that currently opens the Word document:
Sub Create_Emails()
Dim appWD As Object
Dim stPath As String
ActiveWorkbook.Save
stPath = "X:\ProdMgt\RRAdmin\Request Proc\Entitlement and Increased
Access Requests\Templates\Request Denied (EIA) TEMPLATE.doc"
Set appWD = CreateObject("Word.Application") appWD.Visible = True
appWD.Documents.Open (stPath)
appWD.ActiveDocument.MailMerge.MainDocumentType = wdEMail Set appWD =
Nothing
End Sub