Excel Mail Merge - Runtime error 429

dirtychinchilla

Board Regular
Joined
Jun 21, 2013
Messages
234
Hi guys,

So ages ago some helpful chaps here helped me work on this code, which gives users a button in Excel that they can press to transer a quote automatically into a word document via a mail merge. This has been working beautifully for ages, but one user (new) is now getting runtime error 429 when he reaches the "With CreateObject" line. Could anyone give me an insight into what's going wrong?? I'd really appreciate it.

Thanks in advance,

Jonathon

Code:
Sub FSMerge()

    Dim objDoc As String, B As Integer
    
    objDoc = "Q:\Temp\FSTemp.xls"
     
On Error GoTo ErrHandler:

    If MsgBox("Do you want to continue with the mail merge? If nothing happens, check whether a dialog box has opened in the background, or wait 30 seconds and try again. When the dialog box opens, please press yes to accept the mail merge.", vbYesNo, "Confirm") = vbNo Then
        Exit Sub
    End If
    
    ThisWorkbook.SaveCopyAs Filename:=objDoc
    
    With CreateObject("Q:\Index\Documents\Quotation.dotm")
        DoEvents
        .Application.Visible = True
        .MailMerge.Execute
        .Close 0
    End With

    Kill objDoc
     
     'Skip error handler
    Exit Sub
          
ErrHandler:
    Kill objDoc
    MsgBox ("Run-time Error " & Err.Number)
    Exit Sub

End Sub
 
That's wrong, apologies. One thing you'd missed out before is this saving of a temporary file, so I've added it in giving this, which gives error 4605.

Code:
Sub FSMerge()

Dim wrdObj As Object
Dim wrdDoc As Object
Dim objDoc As String, B As Integer

objDoc = "Q:\Temp\FSTemp.xls"
     
On Error GoTo ErrHandler:

    Set wrdObj = CreateObject("Word.Application")

    wrdObj.Visible = True

    ThisWorkbook.SaveCopyAs Filename:=objDoc
    
    Set wrdDoc = wrdObj.Documents.Add(Template:="Q:\Index\Documents\Quotation.dotm")

    wrdDoc.MailMerge.Execute

    wrdDoc.Close 0

    Kill objDoc
     
     'Skip error handler
    Exit Sub
          
ErrHandler:
    Kill objDoc
    MsgBox ("Run-time Error " & Err.Number)
    Exit Sub

End Sub
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
If you remove On Error Goto ErrHandler what's the error message?
 
Upvote 0
Oops I thought the file you were working with was a template.:eek:

Try this.
Code:
Sub FSMerge()

Dim wrdObj As Object
Dim wrdDoc As Object
Dim objDoc As String, B As Integer

objDoc = "Q:\Temp\FSTemp.xls"
     
On Error GoTo ErrHandler:

    Set wrdObj = CreateObject("Word.Application")

    wrdObj.Visible = True

    ThisWorkbook.SaveCopyAs Filename:=objDoc
    
    Set wrdDoc = wrdObj.Documents.Open("Q:\Index\Documents\Quotation.dotm")

    wrdDoc.MailMerge.Execute

    wrdDoc.Close 0

    Kill objDoc
     
     'Skip error handler
    Exit Sub
          
ErrHandler:
    Kill objDoc
    MsgBox ("Run-time Error " & Err.Number)
    Exit Sub

End Sub
 
Last edited:
Upvote 0
Haha not to worry! Same error, I'm afraid.

The Excel document is a standard document, 1997-2003 format though.

The Word template is a template for 1997-2003 I believe.
 
Upvote 0
Has the document been changed?

If you do a manual mail merge with the document in Word with the macro recorder turned on what code, if any, is produced?
 
Upvote 0
Nothing has changed in the document, it still works for everyone except this one guy!!

Sub Macro1()
'
' Macro1 Macro
'
'
ActiveDocument.MailMerge.OpenDataSource Name:="Q:\Temp\FSTemp.xls", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=Q:\Temp\FSTemp.xls;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Engine Type=35;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Glo" _
, SQLStatement:="SELECT * FROM `MailMerge`", SQLStatement1:="", SubType:= _
wdMergeSubTypeAccess
End Sub
 
Upvote 0
Sorry, can't really think of anything other than there being a problem with the one user's setup.
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top