Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / May 2008

Tip: Looking for answers? Try searching our database.

Word 2003 Merge with Sybase Database Query as datasource.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JeffT - 05 May 2008 15:21 GMT
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
Doug Robbins - Word MVP - 05 May 2008 20:33 GMT
Not without seeing the code.  (Though I am not sure that I can help with
VB.NET, but someone may be able to)

Signature

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

> 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
[quoted text clipped - 17 lines]
> Thank you for any help,
> Jeff
JeffT - 06 May 2008 15:01 GMT
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
*************************

> Not without seeing the code.  (Though I am not sure that I can help with
> VB.NET, but someone may be able to)
[quoted text clipped - 20 lines]
> > Thank you for any help,
> > Jeff
Doug Robbins - Word MVP - 06 May 2008 20:53 GMT
Try it without the ((False))

Signature

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

> Doug,
> Thank you for the response.
[quoted text clipped - 111 lines]
>> > Thank you for any help,
>> > Jeff
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.