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

Mail merge

0 views
Skip to first unread message

Abby

unread,
Jun 19, 2002, 6:08:55 PM6/19/02
to

Hello
I have a very basic address table that I use to merge with
Microsoft Word. I also use a form named address form for
data entry for this table. Instead of going into my table
and going through the steps of tools-office links-merge
with MS Word - Link your data with an existing Word
document etc. I would like to create a command button in
my form that when clicked it would automatically do these
steps for me. Is this possible?
Thanks in advance for any suggestions with this.

Rocky Frazier

unread,
Jun 20, 2002, 3:54:02 AM6/20/02
to
You could try a macro designed to do that...ie. open word, etc but I seem to
remember something about the 'sendkeys' function that turns off the
NumLock...


"Abby" <why...@hotmail.com> wrote in message
news:101c201c217dd$e75b3240$b1e62ecf@tkmsftngxa04...

Rocky Frazier

unread,
Jun 20, 2002, 6:22:16 AM6/20/02
to
Or, goto http://support.microsoft.com and read Q159328


"Abby" <why...@hotmail.com> wrote in message
news:101c201c217dd$e75b3240$b1e62ecf@tkmsftngxa04...
>

Jill Pfeffer

unread,
Jun 20, 2002, 3:30:51 PM6/20/02
to
Abby: You and I are in the same boat. I asked your very
same question just a few posts before you. You may want
to refer to my post and the response I received. My
command button is working. Good luck.
>.
>

news.xs4all.nl

unread,
Jun 21, 2002, 9:24:47 AM6/21/02
to

"Abby" <why...@hotmail.com> schreef in bericht
news:101c201c217dd$e75b3240$b1e62ecf@tkmsftngxa04...

I made a function that mailmerge a document with a query. if the document is
a mailmerge document.
Sorry, the msgbox languange en functionname is dutch

Public Function Samenvoegen(WordDocName As String, QueryName As String,
Optional Printen As Boolean)
On Error GoTo Err_Samenvoegen

Dim oApp As Object
Dim dbs As Database
Dim strPad As String
Dim worddoc As Object
Dim blnGevonden As Boolean
Dim QDF As QueryDef
Dim rs As Recordset

DoCmd.Hourglass True
Set dbs = CurrentDb()
strPad = dbs.Name

blnGevonden = False
For Each QDF In dbs.QueryDefs
If QDF.Name = QueryName Then
blnGevonden = True
End If
Next QDF

If blnGevonden = False Then
MsgBox ("De query is niet gevonden"), vbExclamation
GoTo eind
End If

Set rs = dbs.OpenRecordset(QueryName, dbOpenDynaset)
If Not rs.RecordCount > 0 Then
MsgBox ("Er zijn geen gegeven voor deze brief")
GoTo eind
End If

Set oApp = CreateObject("Word.Application")
If Dir(WordDocName) & " " <> " " Then
oApp.Documents.Open (WordDocName)
VerderlegeGegevensBrief:
Set worddoc = oApp.Documents.Item(oApp.ActiveDocument.Name)
Else
MsgBox ("Het bestand is niet gevonden"), vbExclamation
oApp.Quit
GoTo eind
End If

With worddoc.MailMerge
.OpenDataSource strPad, linktosource:=True, addtorecentfiles:=False,
Connection:="QUERY " & QueryName
End With
If worddoc.MailMerge.State = 2 Then 'wdMainAndDataSource
If Not IsMissing(Printen) Then
worddoc.MailMerge.Destination = Abs(CLng(Printen))
Else
worddoc.MailMerge.Destination = 0 'wdSendToNewDocument
End If
worddoc.MailMerge.Execute
End If

worddoc.Close SaveChanges:=0 'wdDoNotSaveChanges
DoCmd.Hourglass False
If Printen = True Then
oApp.Quit
Else
oApp.Visible = True
End If

eind:
DoCmd.Hourglass False
Set worddoc = Nothing
Set oApp = Nothing

Exit_Samenvoegen:
Exit Function

Err_Samenvoegen:
If Err.Number = 5631 Then Resume VerderlegeGegevensBrief
MsgBox Err.Description
Resume Exit_Samenvoegen

End Function


lalexander

unread,
Aug 20, 2002, 1:44:08 PM8/20/02
to
Instead of loading MsWord, ( which undoubtedly takes up memory when
loading ) - you could created a form
and connect to a database or query of your choice.

You can then run the form just like a report.

I've used this technique whenever I'm doing a mailmerge project.

( This is also neat especially when the users/s do no have Msword
Loaded. )

"Abby" <why...@hotmail.com> wrote in message
news:101c201c217dd$e75b3240$b1e62ecf@tkmsftngxa04...
>

0 new messages