Hello!
I am doing an Excel-to-Word Mail Merge.
The merge is over, but the template Word doc stays open instead of closing automatically.
When the user tries to close the template, they get this:
"This file is in use by another application or user (C:\Documents and Settings\...\Normal.dot)". User clicks OK. Save As pops up asking to save Normal.dot. User clicks Cancel. User clicks the x to close the main Word window. New message "Changes have been made that affect the global template, Normal.dot. Do you want to save those changes?" User clicks No. Word closes.
Here is the code:
Is there something missing to prevent all these Normal.dot messages and close the template doc?
??Private Sub btnMakeLabels_Click() Dim MyPath As String, MyCompletePath As String Dim fname As String Application.ScreenUpdating = False MyPath = ActiveWorkbook.Path MyCompletePath = ActiveWorkbook.FullName MailMerge: fname = (MyPath & "\Label Template.doc") Dim appWd As Word.Application Dim WdDoc As Word.Document Set appWd = CreateObject("Word.Application") appWd.Visible = True With appWd Set WdDoc = appWd.Documents.Open(MyPath & "\Label Template.doc") WdDoc.Activate WdDoc.MailMerge.OpenDataSource Name:=(MyPath & "\TagLabelMaker R2a.xls"), _ ConfirmConversions:=False, ReadOnly:=True, LinkToSource:=0, AddToRecentFiles:=False, _ PasswordDocument:="", PasswordTemplate:="", WritePasswordDocument:="", _ WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto, _ Connection:="", SQLStatement:="SELECT * FROM `Labels$`", SQLStatement1:="", SubType:=wdMergeSubTypeAccess With WdDoc.MailMerge .Destination = wdSendToNewDocument .SuppressBlankLines = True With .DataSource .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord End With .Execute Pause:=False End With End With WdDoc.Close savechanges:=wdDoNotSaveChanges Application.CutCopyMode = False Set WdDoc = Nothing Set appWd = Nothing fname = "" Application.ScreenUpdating = True Sheets("RIR (Master)").Select End End Sub
I appreciate the help!
Respectfully,
Lost
Last edited by leaning; 08-10-2011 at 05:56 PM. Reason: Solved!
All,
Found something which worked:
I had "PDFMCustom.dot" as an Add-in. I think it is something added by Adobe 9.
I deleted it, and don't get those messages anymore and the template closes.
<shrug>
Thanks!
Lost
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks