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
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