Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

issue on mergeing word document on secured ACCESS

Status
Not open for further replies.

sealahu

Programmer
Aug 5, 2003
16
US
I try to merge word document from ACCESS. Every thing looks good. but because my access database have security set up. so everytime I start to run macro to start mail merge, It pop up a window to ask you userid and password.
I wonder is there any way I could hard code in the VBA code.

My function is:

Function MergeIt()

On Error GoTo ErrorHandler

Dim objWord As Word.Document
Set objWord = GetObject("D:\unfinished project\Investment Agency.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Northwind database.
objWord.MailMerge.OpenDataSource _
Name:="D:\unfinished project\TEST Secure Consent.mdb", _
LinkToSource:=False, _
Connection:="QUERY qryLabelQuery", _
SQLStatement:="Select * from `qryLabelQuery`"
' Execute the mail merge.
objWord.MailMerge.Execute

Set objWord = Nothing

ErrorHandler:
MsgBox "Error #" & Err.Number & " occurred. " & Err.Description, vbOKOnly, "Error"
Exit Function

End Function

I wonder in somewhere in objWord.MailMerge.OpenDataSource ,
I could hard code userid and password for that.

Any idea?
 
If you use a code i.e. a commandbutton in stead of the macro call, this problem should go away.

"Say NO to macroes" B-)

Herman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top