R
Rebecca
Basically, I am using the following code in my Access
database to print the records in the query "Customers"
with the mail merge main document "MyMerge.doc" and
sending it directly to the user's default printer. The
user is currently logged in to the database specified in
the OpenDataSource, in this example, the Northwind
database. When this portion of the code runs, the user is
prompted again to enter his username/password for this
database, though he has it open and is working from it.
How can I A) pass the username/password without hard
coding it into the function (a security risk) OR B) have
the "objWord.MailMerge" specify the current database and
therefore not ask for username/password, OR C) just hide
the username/password dialog box (since if you wait long
enough without entering the username/password the merge
prints to the default printer anyway)?
THANKS!!
Function MergeIt()
Dim objWord As Word.Document
Set objWord =
GetObject "C:\MyMerge.doc", "Word.Document")
' Set the mail merge data source as the Northwind
database.
objWord.MailMerge.OpenDataSource _
Name:="C:\Program Files\Microsoft " & _
"Office\Office\Samples\Northwind.mdb", _
LinkToSource:=True, _
Connection:="QUERY Customers"
' Print the mail merge.
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
objWord.Application.Quit wdDoNotSaveChanges
End Function
database to print the records in the query "Customers"
with the mail merge main document "MyMerge.doc" and
sending it directly to the user's default printer. The
user is currently logged in to the database specified in
the OpenDataSource, in this example, the Northwind
database. When this portion of the code runs, the user is
prompted again to enter his username/password for this
database, though he has it open and is working from it.
How can I A) pass the username/password without hard
coding it into the function (a security risk) OR B) have
the "objWord.MailMerge" specify the current database and
therefore not ask for username/password, OR C) just hide
the username/password dialog box (since if you wait long
enough without entering the username/password the merge
prints to the default printer anyway)?
THANKS!!
Function MergeIt()
Dim objWord As Word.Document
Set objWord =
GetObject "C:\MyMerge.doc", "Word.Document")
' Set the mail merge data source as the Northwind
database.
objWord.MailMerge.OpenDataSource _
Name:="C:\Program Files\Microsoft " & _
"Office\Office\Samples\Northwind.mdb", _
LinkToSource:=True, _
Connection:="QUERY Customers"
' Print the mail merge.
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
objWord.Application.Quit wdDoNotSaveChanges
End Function