Mail Merge from Access with datasource being a password protected

  • Thread starter Thread starter Rose B
  • Start date Start date
R

Rose B

I have an Access application distributed to users of Office 2003 and Office
2007 via a runtime front end. The application needs to trigger a Mail Merge
which will use query results in back end, which is protected by a password.

I have coded in VB to cope with this in an Office 2007 environment - but
when running with Office 2003 Word is asking for the data source when
initially opening the mail merge document from Accesss; when opened directly
it does not ask for the data source and when responding with "No" to the SQL
prompt it opens fine. Can anyone help?

My code is

With myWordDoc.MailMerge
.OpenDataSource Name:="", ConfirmConversions:=False,
ReadOnly:=False, LinkToSource:=False, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="",
Revert:=False, _
Format:=0, _
Connection:="DSN=MS Access Database;DBQ=" & DataSource &
";DriverId=25;FIL=MS
Access;MaxBufferSize=2048;PageTimeout=5;PWD=mypassword;UID=admin;" _
, SQLStatement:=mySQL, SQLStatement1:="", SubType:=1
.Destination = myDestination
.MailAddressFieldName = "Email"
.ViewMailMergeFieldCodes = False
.SuppressBlankLines = True
With .DataSource
.FirstRecord = 1
.LastRecord = -16
End With
.Execute Pause:=False
End With
 
I have an Access application distributed to users of Office 2003 and Office
2007 via a runtime front end. The application needs to trigger a Mail Merge
which will use query results in back end, which is protected by a password.

I have coded in VB to cope with this in an Office 2007 environment - but
when running with Office 2003 Word is asking for the data source when
initially opening the mail merge document from Accesss; when opened directly
it does not ask for the data source and when responding with "No" to the SQL
prompt it opens fine. Can anyone help?

My code is

    With myWordDoc.MailMerge
        .OpenDataSource Name:="", ConfirmConversions:=False,
ReadOnly:=False, LinkToSource:=False, _
           AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
           WritePasswordDocument:="", WritePasswordTemplate:="",
Revert:=False, _
           Format:=0, _
           Connection:="DSN=MS Access Database;DBQ=" & DataSource &
";DriverId=25;FIL=MS
Access;MaxBufferSize=2048;PageTimeout=5;PWD=mypassword;UID=admin;" _
           , SQLStatement:=mySQL, SQLStatement1:="", SubType:=1
         .Destination = myDestination
         .MailAddressFieldName = "Email"
         .ViewMailMergeFieldCodes = False
         .SuppressBlankLines = True
            With .DataSource
                .FirstRecord = 1
                .LastRecord = -16
            End With
         .Execute Pause:=False
    End With

What if you used Albert's code for Super Easy Word Merge? Because it
exports to a delimited text file, you could use that as the source and
not have to deal with the security issues.
 
Back
Top