Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Merge problem

0 views
Skip to first unread message

Bouwman P.

unread,
Mar 20, 2003, 3:07:48 AM3/20/03
to
Hi, (vb6, sp5)
Our Visual Basis program does a merge operation with Word. The values for
the merge
fields are in an Access DB, called Selektie.mdb.
The Access DB has 'shared' access.

Two of my customers have the problem that the merge goes wrong. (one
customer with XP Pro, the other I forgot) They get error number 5631 saying
that "the DDE to Access is impossible; merge needs access to the data or
there is no data at all".
In Explorer the Selektie.ldb file remains present after closing the program.

I checked that the data in selektie.mdb is actually there. So in my humble
opinion it is some sort of locking problem.

Does someone recognise this?
Peter


Bouwman P.

unread,
Mar 20, 2003, 7:15:17 AM3/20/03
to
I think I need to add info to my earlier mail on the subject.

The code below shows how i do the merge of data into a word doc.
The user has made a template containing the text and the merge fields.
When the user wants to do the actual merge:
1. the user chooses the needed template and presses the Print button in my
app.
2. Word opens first the template.
3. Then Word opens the new document which shows the ultimate doc. with the
merge values merged in
4. Next, normally the user closes the 2 documents, and all's fine.

5. Now however, the systen does not close the first doc, the template.
Therefore keeping the
link open to Access. Therefore the .ldb file remains visible.
When my customer wants to close his computer down, then it asks if user
wants to close remaining app. Then that template doc get closed.


Please need urgent assistance on this.
Peter

In the code below, the Access DB with the merge values is called
Selektie.mdb, which contains a table with the same name 'selektie'.

******** CODE ********************

Option Explicit

Sub Main()

Dim WordAppl As Object 'Word.Application
Dim MyApplic As New BiApplic.Applic
Dim MyMailMerge As Object 'MailMerge
Dim oDoc As Object

Dim sDoc As String
Dim sDocType As String
Dim sSendTo As String
Dim CmlParamArr As Variant
Dim connstr As String
Dim WVersion As String

Set WordAppl = CreateObject("Word.Application")

WVersion = WordAppl.Version

'verwerk command line param's
MyApplic.Commandline = Command
CmlParamArr = MyApplic.ParamArr
sDoc = CmlParamArr(1)
sSendTo = CmlParamArr(2)
sDocType = CmlParamArr(3)


Set oDoc = WordAppl.Documents.Open(FileName:=sDoc)
oDoc.Activate
Set MyMailMerge = oDoc.MailMerge

If sDocType = "Tabel" Then
MyMailMerge.MainDocumentType = wdCatalog
Else
MyMailMerge.MainDocumentType = wdFormLetters
End If

connstr = "DSN=BISelekt;UID=Admin;PWD=;"

If WVersion = "9.0" Then
'Office 2000
MyMailMerge.OpenDataSource Name:="", _
LinkToSource:=True, AddToRecentFiles:=False, _
Connection:=connstr, SQLStatement:="select * from selektie"
End If
If WVersion = "10.0" Then
'Office XP
MyMailMerge.OpenDataSource Name:="", _
LinkToSource:=True, AddToRecentFiles:=False, _
Connection:=connstr, SQLStatement:="select * from selektie", _
SubType:=wdMergeSubTypeWord2000
End If

'Default
WordAppl.Visible = True

MyMailMerge.Destination = wdSendToNewDocument
If sSendTo = "Printer" Then
MyMailMerge.Destination = wdSendToPrinter
End If

MyMailMerge.Execute

oDoc.Close

Set MyMailMerge = Nothing
Set oDoc = Nothing

End Sub
"Bouwman P." <pbou...@wxs.nl> wrote in message
news:b5bsqf$dq$1...@reader10.wxs.nl...

Cindy Meister -WordMVP-

unread,
Mar 20, 2003, 11:47:12 AM3/20/03
to
Hi Bouwman,

> 4. Next, normally the user closes the 2 documents, and all's fine.
>
> 5. Now however, the systen does not close the first doc, the template.
> Therefore keeping the
> link open to Access. Therefore the .ldb file remains visible.
> When my customer wants to close his computer down, then it asks if user
> wants to close remaining app. Then that template doc get closed.
>

Can you determine if the doc is being kept open by a message prompt? Make
the Word application visible, before you activate it, and watch if Word
is asking if you want to save changes to oDoc, perhaps? Try specifying
the DoNotSaveChanges argument in the .Close method, and see if that
helps.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)

0 new messages