Word 2003 Merge with Sybase Database Query as datasource.

J

JeffT

Hello. I am a newbie here. I need some help.
A little history: I wrote a form letter generation system in VB 4.0 about 10
years ago and it has been used to merge data into many thousands of letters
usin MS word 2.0.
The problem: My company now says we have to upgrade the servers and Word for
security reasons. I have converted the VB program to VB.NET and upgraded Word
to Microsoft Office Word 2003 (11.8202.8202) SP3. But nothing works.
The program launches correctly and connects to the Sybase database, gets its
recordset of variables to merge and then opens Word, and Stops at the point
the merge is supposed to take place.
Does anyone have any I dea of a setting or option that I might need to change?
I already turned off all the options in the track changes section.
Thank you for any help,
Jeff
 
D

Doug Robbins - Word MVP

Not without seeing the code. (Though I am not sure that I can help with
VB.NET, but someone may be able to)

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

JeffT

Doug,
Thank you for the response.
Here is the sub routine that merges the documents.
The process stops at the line with *=*=*=*=*=*=*=*=*
Any ideas would be appreciated.
No errors are returned, the process just stops.

*********************************
Public Sub Do_MailMerge(ByRef wdapp As Word.Application)

Dim adoMergeRS As ADODB.Recordset
Dim strSQL As String
On Error GoTo MergeError

strSQL = "Select * from " & tablename & " where swLetterHistId = " &
adoInitialRS.Fields("swLetterHistId").Value

adoMergeRS = New ADODB.Recordset
'Opening the recordset
adoMergeRS.Open(strSQL, dbconnection, ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockOptimistic)

'Do the mail merge
'' wdapp.Documents(1).MailMerge.MainDocumentType = wdFormLetters''
wdapp.Documents(1).MailMerge.OpenDataSource Name:="",
ConfirmConversions:=False, _
''' ReadOnly:=False,
Connection:="dsn=inCITe1;uid=swb;pwd=vantive;database=vantive",
LinkToSource:=True, AddToRecentFiles:=False, _
''' PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _
''' WritePasswordTemplate:="", Revert:=False,
Format:=wdOpenFormatAuto, _
''' SQLStatement:=strSQL
wdapp.Documents.Item(1).MailMerge.MainDocumentType =
Word.WdMailMergeMainDocType.wdFormLetters
wdapp.Documents.Item(1).MailMerge.OpenDataSource(Name:="",
ConfirmConversions:=False,
ReadOnly:=False,
Connection:=strDSN,
LinkToSource:=True,
AddToRecentFiles:=False,
PasswordDocument:="",
PasswordTemplate:="",
WritePasswordDocument:="",
WritePasswordTemplate:="",
Revert:=False,
Format:=Word.WdOpenFormat.wdOpenFormatAuto, SQLStatement:=strSQL)

'"DSN=inCITe;uid=swb;pwd=Pswrd"
With wdapp.Documents.Item(1).MailMerge *=*=*=*=*=*=*=*=**=*=*=*
.SuppressBlankLines = True
.Destination = Word.WdMailMergeDestination.wdSendToNewDocument
.Execute((False))
End With

'Free Memory
strSQL = ""

'MsgBox "Mailmerge successful so far"

Exit Sub
MergeError:
' MsgBox "Check table " & adoInitialRS!swLetterHistId
Select Case Err.Number
Case 5631 'No records matched the select or they were empty
blnMergeFailed = True
Error_Logger(Err.Number, Err.Description, "Do Mail Merge")
Case 5922 'Word was unable to open the data source
Error_Logger(Err.Number, Err.Description, "Do Mail Merge")
blnMergeFailed = True
Case 462 'The ODBC Connection has been lost,
'Database server or network Connection has failed
Error_Logger(Err.Number, Err.Description, "Do Mail Merge")
blnMergeFailed = True
Close_dbConnection()
Case -2147418111 'Automation error Call was rejected by callee.
Error_Logger(Err.Number, Err.Description, "Do Mail Merge")
blnMergeFailed = True
Close_dbConnection()
Case Else
Error_Logger(Err.Number, Err.Description, "Do Mail Merge")
blnMergeFailed = True
End Select
End Sub
*************************
 
D

Doug Robbins - Word MVP

Try it without the ((False))

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top