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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command Button Mail Merge stopped working when I added a Password

Status
Not open for further replies.

shuttlelaunch

Technical User
Sep 22, 2011
15
US
I used to use the code below on a command button in Access to fill form letter (.docx).



If Me.Dirty Then Me.Dirty = False
Set ObjWord = GetObject("C:\MY DOCUMENTS\FORM LETTER.docx", "Word.Document")
ObjWord.Application.Visible = True
ObjWord.MailMerge.OpenDataSource _
Name:=" C:\MY DOCUMENTS\FORM LETTER\MEMBERS DATA BASE _be.accdb", _
LinkToSource:=True, _
Connection:="TABLE MASTER DATA BASE", _
SQLStatement:="SELECT * FROM [MASTER DATA BASE] WHERE ID = " & Me.ID
ObjWord.MailMerge.Destination = wdSendToNewDocument
ObjWord.MailMerge.Execute
ObjWord.Application.Options.PrintBackground = False



It worked fine, but I recently encrypted the database with a password. Now when I click the button on the form, Word opens and I get a message "Error has occured: Not a valid password". How can I add the password to the VB script so that the command button will work again?

Thanks!!
 
Have you tried PWD:="My Password", ?

HTH << MaZeWorX >> "I have not failed I have only found ten thousand ways that don't work" <<Edison>>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top