shuttlelaunch
Technical User
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!!
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!!