Run-time error '4198'

l KAUTION l

Board Regular
Joined
Nov 3, 2005
Messages
90
I have been searching for an answer to this question, but have failed to find one.

I'm getting Run-time error '4198': Command failed while trying to run this code.

wrd.ActiveDocument.MailMerge.OpenDataSource Name:= _
"O:\Xerox\Conversions\Heacock\ReminderLetters 122909.xls" _
, ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=O:\Xerox\Conversions\Heacock\ReminderLetters 122909.xls;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Regi" _
, SQLStatement:="SELECT * FROM `Sheet2$`", SQLStatement1:="", _
SubType:=wdMergeSubTypeAccess

I'm basically trying to do a mail merge through vba. Similiar code works on a different spreadsheet I've created. The following code is prior to the code above:

Dim wrd As Object

Set wrd = CreateObject("Word.Application")
wrd.Visible = True

wrd.Documents.Open Filename:="O:\Xerox\Conversions\Heacock\Heacock 15 day reminder notice for offers UPDATED 101209.doc"

I would greatly appreciate any help with this!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Do you have a reference set to the Word object library? If not, you cannot use Word constants (such as wdOpenFormatAuto and wdMergeSubTypeAccess) without declaring them yourself.
 
Upvote 0
Do you have a reference set to the Word object library? If not, you cannot use Word constants (such as wdOpenFormatAuto and wdMergeSubTypeAccess) without declaring them yourself.

I didn't even think to check this. Problem solved thank you!!
 
Upvote 0

Forum statistics

Threads
1,214,428
Messages
6,119,420
Members
448,895
Latest member
omarahmed1

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