Error 4198 Mail Merge
Contents |
SQL Server 2014 Express resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs error 4198 command failed Channel 9 Documentation APIs and reference Dev centers Retired content Samples
Error 4198 Vba
We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: Word 2010 VBA: Run-time error '4198' Command Failed - MailMerge Microsoft Office for Developers > Word for Developers Question 0 Sign in to vote I have written a function in Excel 2010 using VBA that performs a mail merge in Word 2010 using a CSV file that I generatedwith data from the Excel workbook. Function EmailVerstuurd() As Boolean Dim appWord As Word.Application Dim blnRunning As Boolean Dim doc As Document Dim strEmailInloggen As String Dim strRegje As String Dim i As Integer, rMail As Range Dim secAutomation As MsoAutomationSecurity 1 On Error GoTo Err_handler 'Capture the name of the procedure for debugging purposes 2 strProcedure = "EmailVerstuurd" 'Full path of mail merge main document 3 strEmailInloggen = "V:\Opleiding\Bedrijfsopleidingen\Typecursus\Procedures\Email inloggegevens nieuwe gebruiker.doc" 'Check if an instance of Word is already running 4 If modCode.IsAppRunning("Word.Application") Then 5 Set appWord = GetObject(, "Word.Application") 6 blnRunning = True 7 Else 8 Set appWord = CreateObject("Word.Application") 9 End If 'If necessary set registry key kb825765 / http://vba-corner.livejournal.com/3054.html 10 strRegje = "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Word\Options\SQLSecurityCheck" 11 If Not modFunctions.RegKeyExists(strRegje) Then 12 modFunctions.RegKeySave strRegje, "00000000", "REG_DWORD" 13 End If 'Put security to low kb886633 14 secAutomation = appWord.AutomationSecurity 15 appWord.AutomationSecurity = msoAutomationSecurityLow 'Open mail merge main document 16 Set doc = appWord.Documents.Open(FileName:=strEmailInloggen) 'Perform the mail merge - send email to selected recipients 17 With doc.MailMerge 18 .OpenDataSource Name:=ActiveWorkbook.Path & "\" & "Import_TypingMaster.csv" 19 .Destination = wdSendToEmail 20 .MailAsAttachment = False 21 .MailSubject = "Inloggeven
visit from the selection below. Home » Microsoft Office Word Forum - WordBanter forum » Microsoft Word Newsgroups » Mailmerge doc.Mailmerge.datasource.querystring=strSQL; Command Failed: Run-Time error 4198 Author Name Remember Me? Password Site Map Home Register Authors List Today's Posts Search Web Partners Search Forums Show Threads Show Posts Advanced Search Go to Page... doc.Mailmerge.datasource.querystring=strSQL; Command Failed: Run-Time error 4198 « Previous Thread | Next Thread » Thread Tools Display Modes #1 February 13th 07, 06:05 PM posted to microsoft.public.word.mailmerge.fields weisinator external usenet poster Posts: 2 https://social.msdn.microsoft.com/Forums/en-US/99af2bc9-d2ee-4036-9901-afbc4c1b1174/word-2010-vba-runtime-error-4198-command-failed-mailmerge?forum=worddev doc.Mailmerge.datasource.querystring=strSQL; Command Failed: Run-Time error 4198 Automated mail merge, I thought this would be easy, lol. MS Access 2000, Word 2002. Executing from Word VBA custom form. I currently populate my custom form's group selection listbox with the recordset. I know I have a connection to the database, just not with the mail merge. The group list selected value is used in the SQL statement I would like to http://www.wordbanter.com/showthread.php?t=74880 use for pulling mail merge records. The SQL statement is valid (though ugly) and pulls data from the tables as intended when I use it within Access. However, if I exclude the "SQLStatement" parameter from the OpenDataSource, it pops up with a table. I want to avoid that, so I threw some generic code in there. My problem comes with the document.mailmerge.datasource.querystring property. I get "command failed" when I try to set it equal to strQry. Doesn't matter if SQLStatement is populated or not. Code: ----------------------------------------------------------------------------------- Private Sub btnBeginMerge_Click() Set docMerge = ActiveDocument Dim strQry As String strQry = "SELECT g.Grp, g.Ppl, " _ & "p.Ttl, p.Frstnm, p.Mddlnm, p.Lstnm, " _ & "a.Cmpny, a.Strt1, a.Strt2, a.Cty, a.Stt, a.Zp " _ & "FROM Addrss AS a, Ppl AS p, GrpMmbr AS g " _ & "WHERE g.Grp = " & drpGrpLst.Value & " " _ & "AND g.Ppl = p.Id " _ & "AND p.Id = a.Ppl;" Debug.Print strQry With docMerge.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource Name:= _ dbPath, _ ConfirmConversions:=False, _ ReadOnly:=False, _ LinkToSource:=True, _ AddToRecentFiles:=False, _ PasswordDocument:="", _ PasswordTemplate:="", _ WritePasswordDocument:="", _ WritePasswordTemplate:="", _ Revert:=False, _ Format:=wdOpenFormatAuto, _ Connection:= _ "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";Us er ID=Admin;Data Source=" & dbPath & ";Mode=Read;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path=
try to run the macro I receive the message "Runtime Error http://microsoft.public.word.vba.general.narkive.com/2L0OGOWQ/runtime-error-4198-in-mail-merge-maco 4198" and"Execute Pause:=False" is highlighted when I edit the http://www.vbaexpress.com/forum/showthread.php?48989-Run-time-error-5922-Mail-Merge macro in VB Editor.The macro definition is:Documents.Add DocumentType:=wdNewBlankDocumentActiveDocument.MailMerge.MainDocumentType = wdCatalogActiveDocument.MailMerge.OpenDataSource Name:= _"F:\CM3\ASB\REPORTS\ASBMESO.DAT", ConfirmConversions:=False,ReadOnly:= _False, LinkToSource:=True, AddToRecentFiles:=False,PasswordDocument:="", _PasswordTemplate:="", WritePasswordDocument:="",WritePasswordTemplate:= _"", Revert:=False, Format:=wdOpenFormatAuto, Connection:="",SQLStatement _:="", SQLStatement1:="", SubType:=wdMergeSubTypeOtherWith ActiveDocument.MailMerge.Destination = wdSendToNewDocument.SuppressBlankLines = TrueWith .DataSource.FirstRecord = wdDefaultFirstRecord.LastRecord = wdDefaultLastRecordEnd With.Execute Pause:=TrueEnd error 4198 WithEnd SubThanks in advance for any help you can provide. zkid 2006-04-03 01:15:01 UTC PermalinkRaw Message What type of program created your .dat file?Post by sstiresI am very new to Word Macros and recorded a macro to perform a mail merge.When I try to run the macro error 4198 mail I receive the message "Runtime Error 4198" and"Execute Pause:=False" is highlighted when I edit the macro in VB Editor.Documents.Add DocumentType:=wdNewBlankDocumentActiveDocument.MailMerge.MainDocumentType = wdCatalogActiveDocument.MailMerge.OpenDataSource Name:= _"F:\CM3\ASB\REPORTS\ASBMESO.DAT", ConfirmConversions:=False,ReadOnly:= _False, LinkToSource:=True, AddToRecentFiles:=False,PasswordDocument:="", _PasswordTemplate:="", WritePasswordDocument:="",WritePasswordTemplate:= _"", Revert:=False, Format:=wdOpenFormatAuto, Connection:="",SQLStatement _:="", SQLStatement1:="", SubType:=wdMergeSubTypeOtherWith ActiveDocument.MailMerge.Destination = wdSendToNewDocument.SuppressBlankLines = TrueWith .DataSource.FirstRecord = wdDefaultFirstRecord.LastRecord = wdDefaultLastRecordEnd With.Execute Pause:=TrueEnd WithEnd SubThanks in advance for any help you can provide. sstires 2006-04-03 14:06:02 UTC PermalinkRaw Message The data was pulled from STI's "Practice Master" and saved as Word merge filedata.Post by zkidWhat type of program created your .dat file?Post by sstiresI am very new to Word Macros and recorded a macro to perform a mail merge.When I try to run the macro I receive the message "Runtime Error 4198" and"Execute Pause:=False" is highlighted when I edit the macro in VB Editor.Documents.Add DocumentType:=wdNewBlankDocumentActiveDocument.MailMerge.MainDocumentType = wdCatalogActiveDocument.MailMerge.OpenDataSource Name:= _"F:\CM3\ASB\REPORTS\ASBMESO.DAT", ConfirmConversions:=False,ReadOnly:= _False
VBA Code & Other Help Word Help Run-time error '5922' - Mail Merge If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Page 1 of 5 1 2 3 ... Last Jump to page: Results 1 to 20 of 82 Thread: Run-time error '5922' - Mail Merge Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 02-20-2014,07:39 AM #1 dirtychinch View Profile View Forum Posts View Blog Entries Visit Homepage View Articles VBAX Regular Joined Feb 2014 Location Ashford, Surrey, UK Posts 64 Location Run-time error '5922' - Mail Merge Afternoon all, Sorry for the mislead title - I had that error previously and will probably have it again, but another hump got in the way, so I amended my post. I'm trying to set up a mail merge from Excel to Word. I've got it working manually, but need to automate the process for our users. I have the macro below run in an AutoNew sub, when the document opens. However, every time I try and use it, after one clicks Yes to continue with the mail merge, it comes up with the error "Object doesn't support this property or method." Sub MailMerge() Dim SourceDoc As String Dim SelectedItems(1) As String With Application.FileDialog(msoFileDialogFilePicker) .AllowMultiSelect = False If .Show <> 0 Then SelectedItems(1) = SourceDoc Else Exit Sub End If End With ActiveDocument.MailMerge.OpenDataSource Name:=SourceDoc, _ ConfirmConversions:=True, 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=H:\Jonathon Hunter Hill\Mail Merge\AirMaster V 0.9.xlsm;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Engine Type=35;Jet OLEDB:" _ , SQLStatement:="SELECT * FROM `MailMerge$`", SQLStatement1:="", SubType _ :=wdMergeSubTypeAccess End Sub Formatting tags added by mark007 If I click No to the question of whether I want to carry out the mail merge or not, I can then run this macro again and it will get past that initial Object error stage. However, it then allows me to select a document (which I am able to mail merge manually), and then I can select the Provider (OLED), despite that choice already being filled (I think) at which point the 5922 error occurs and the sub te