Access/Word integration Mail Merge issue

  • Thread starter Michael Suttkus, II
  • Start date
M

Michael Suttkus, II

I'm automating an Access database. One of the functions that it must perform
is to print out envelopes to certain addresses stored in the database. I've
put the code below into a command button, but when it is run, several dialog
boxes come up, specifically "Data Link Properties", "Confirm Data Source" and
"Log In".

This is unacceptable. The point of automation is to prevent the user from
having to make choices like this, especially such abstruse ones that will not
make the slightest bit of sense to most of my end-users.

Further, it just shouldn't happen, since most of the choices being asked of
the user have already been indicated in the code, so obviously I'm doing
something incorrectly.

Any help would be appreciated.

(Also, tell me if I'm posting this to the wrong forum, the groups here
aren't always clearly delineated.)

Private Sub cmdPrintEnvelopes_Click()
Dim WordApp As Word.Application
Dim WordDoc As Word.Document

Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
Set WordDoc = WordApp.Documents.Open(Application.CurrentProject.Path &
"\envelopes.doc", , True, False, , , , , , , , True)

With WordDoc.MailMerge
.Destination = wdSendToPrinter
.OpenDataSource _
Name:=Application.CurrentProject.FullName, _
ReadOnly:=True, _
LinkToSource:=False, _
AddToRecentFiles:=False, _
PasswordDocument:="EZ4ME", _
Revert:=False, _
Connection:="QUERY Envelopes"

.Execute
End With

WordDoc.Close False
WordApp.Quit wdDoNotSaveChanges
End Sub
 
M

Michael Suttkus, II

I'm really getting a bit desperate here.

I've tried doing this very simple task a dozen different ways without
success. Each solution either refuses to work or requires the user to make
several abstruse choices (i.e., fails to be automation at all).

The annyoing thing is that it works so simply manually. If I open up the
Envelopes.doc file, it puts up a dialog box indicating it will run an SQL,
requiring the user to do nothing more complicated than select "Yes", and then
"Merge to Printer".

However, when trying to do this programatically, it refuses to automatically
open the datasource, and certainly doesn't present any dialog box as simple
as the "Yes to SQL" box from the manual opening.

This problem is too simple to be this frustrating.
 
T

TC

Where do you say the name of the Access database? All I see is:

Name:=Application.CurrentProject.FullName

but that doesn't look right.

TC
 
M

Michael Suttkus, II

As the code is running in Access, that resolves to the name of the file the
codes is being run from.
 

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