ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   "is now available for editing" problem with Excel-automated mail merge (https://www.excelbanter.com/excel-programming/396380-now-available-editing-problem-excel-automated-mail-merge.html)

Melissa[_3_]

"is now available for editing" problem with Excel-automated mail merge
 
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 Processing\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



All times are GMT +1. The time now is 01:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com