Data source connection problem using MailMerge in VB6 with Word 20
- From: Flightmeister <Flightmeister@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 8 Dec 2006 02:53:02 -0800
Hi,
I've tried looking everywhere for a solution to this problem but haven't
found anything that's worked, so I'd thought I'd try this forum. If someone
could help, I'd be extremely grateful!
I have a VB6 program that allows the user to generate a letter in Word from
a form via the MailMerge facility within VB. It's worked fine for the past
year or more up until a couple of weeks ago, when the users' version of Word
was upgraded from 2000 to 2003. Now when a letter generation is performed, it
comes up with a 'Select Data Source' dialogue box and creates the document
correctly once the data source has been selected. Before, it was
automatically connecting to the data source (an Oracle database) with no user
intervention required, and producing the document. Does anyone know why this
is happening, and what I need to do to stop this dialogue box appearing? I've
tried things such as including a SubType:=wdMergeSubTypeWord2000 statement,
and debugging the code line by line, but all to no avail.
The code looks like this:
Public Sub mailMerge(enmType As Letters, lKey As Long)
On Error GoTo mailMergeError
Dim oApp As Word.Application
Dim oMainDoc As Word.Document
Dim oSel As Word.Selection
Set oApp = startWord
oApp.Visible = True
Dim sDir As String
sDir = App.Path & "\letters\" & getUserId
Dim sFile As String
sFile = getLetterDescs()(enmType) & ".doc"
Set oMainDoc = oApp.Documents.Open(sDir & "\" & sFile)
With oMainDoc.mailMerge
.MainDocumentType = wdFormLetters
Dim sSql As String
sSql = modIO.getClaimSummarySql(lKey)
.OpenDataSource Name:="" _
, Connection:=modIO.getMailMergeConnectionString _
, SQLStatement:=sSql _
, SubType:=wdMergeSubTypeWord2000
End With
With oMainDoc
.mailMerge.Destination = wdSendToNewDocument
.mailMerge.Execute Pause:=False
End With
oMainDoc.Close
normalExit:
Set oApp = Nothing
Set oMainDoc = Nothing
Set oSel = Nothing
On Error GoTo 0
Exit Sub
End Sub
The connection string looks like this:
"DSN=ics_test;UID=insurance_claims_user;PWD=userofinsuranceclaimstest;DBQ=GP0T"
As I said, this code was working fine with Word 2000, but not with Word
2003. Has anyone else had this problem? I'm a bit of a newbie when it comes
to VB, this program was written by a predecessor of mine and I've been thrown
in at the deep end with the task of supporting it. I've spent many a
frustrating hour trying to solve this problem so any advice / suggestions
gratefully received so I can hang to to the little hair I have left!
Thanks,
Chris
.
- Prev by Date: Re: Why "microsoft odbc for oracle" not work?
- Next by Date: Re: Saving DAO recordset
- Previous by thread: Re: Why "microsoft odbc for oracle" not work?
- Next by thread: Re: Saving DAO recordset
- Index(es):
Relevant Pages
|