Reply
 
Thread Tools Display Modes
  #1   Report Post  
sparty1022
 
Posts: n/a
Default get error 5361 in mailmerge automation

automating Word 2003 from vb6 program to mailmerge into a letter the
following is my code:

pstrRS1 = "select lname, ssn, address1, city, state, zip, phone from person
where personid = '" & breederid & "'"
Debug.Print pstrRS1

pcon.Open gConnectString
rsPayee.Open pstrRS1, pcon, adOpenForwardOnly, adLockReadOnly, adCmdText


If rsPayee.EOF = True Then
pcon.Close
Set pcon = Nothing
MsgBox "There is no Person record for this Breeder", vbCritical,
"Missing Person record for Breeder"
Exit Sub
Else

'create an instance of word and make it visible
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = False

'What document do I want to open
SetMMPath
Set wrdDoc = wrdApp.Documents.Open(gstrPayeeReg)
wrdDoc.Select
Set wrdSelection = wrdApp.Selection
Set wrdMailMerge = wrdDoc.MailMerge
End If

iRow = 2
wrdDoc.MailMerge.CreateDataSource
Name:="C:\windows\temp\NewPayeeDataDoc.doc", _
headerrecord:="LName, SSN, LName1, Address1, City, State, Zip, Phone"

Set wrdDataDoc =
wrdApp.Documents.Open("C:\windows\temp\NewPayeeDat aDoc.doc")


lname = rsPayee!lname
SSN = IIf(Not IsNull(rsPayee!SSN), rsPayee!SSN, "")
Address1 = IIf(Not IsNull(rsPayee!Address1), rsPayee!Address1, "")
city = IIf(Not IsNull(rsPayee!city), rsPayee!city, "")
State = IIf(Not IsNull(rsPayee!State), rsPayee!State, "")
zip = IIf(Not IsNull(rsPayee!zip), rsPayee!zip, "")
If Len(rsPayee!Phone) = 7 Then
Phone = Format(rsPayee!Phone, "###-####")
ElseIf Len(rsPayee!Phone) = 10 Then
Phone = Format(rsPayee!Phone, "(###)###-####")
Else
Phone = ""
End If

FillpayeeReg wrdDataDoc, iRow, lname, SSN, lname, Address1, city, State,
zip, Phone

wrdMailMerge.Destination = wdSendToNewDocument
wrdMailMerge.Execute False *********Error
occurs here
wrdApp.Options.PrintBackground = False
wrdApp.ActiveDocument.PrintOut
wrdApp.ActiveDocument.Close True

wrdDataDoc.Saved = True
wrdDataDoc.Close True

wrdDoc.ActiveWindow.Close True
wrdApp.Quit

Set wrdSelection = Nothing
Set wrdMailMerge = Nothing
Set wrdMergeFields = Nothing
Set wrdDataDoc = Nothing
Set wrdDoc = Nothing
Set wrdApp = Nothing

'mrstViolations.Close
rsPayee.Close
pcon.Close
Set pcon = Nothing


I had previously used this code in Word2000 without issues what is happening
now?

I based this off the kb 220607 article.
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mailmerge Robert Mailmerge 0 August 19th 05 12:24 AM
Trying to suppress Select Table box in Excel-Word mailmerge Denise Mailmerge 4 June 21st 05 01:08 PM
Protect mailmerge document BillM Mailmerge 1 June 9th 05 12:58 PM
Textboxes in Mailmerge? zSplash Mailmerge 5 March 22nd 05 09:01 PM
Included Property in Word 2003 MailMerge Alessio Mailmerge 1 December 23rd 04 11:26 AM


All times are GMT +1. The time now is 10:02 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"