Hi,
I have a VB6 application that creates a mail merge document in Microsoft Word 2003. What I would like to do is either after the mail merge process is complete, password protect the document so no one can edit it or password protect the document before the mail merge, open the word document, enter the password so I can perform the mail merge then make sure that no one can edit the document.
Here is my code to open the document:
wrdDoc.MailMerge.OpenDataSource name:=App.Path & "\" & CurrentUser$ & "\mailmerge.xls", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source= App.Path & '\' & CurrentUser$ & '\mailmerge.xls';Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB
atabase Password=""""", _
SQLStatement:="SELECT * FROM `Sheet1$`", SQLStatement1:="", SubType:=wdMergeSubTypeAccess
I tried entering a password in the passworddocument, passwordtemplate, writepassword, and writepasswordtemplage field but I keep getting a cannot open document because it is password protected. I also tried using wrdDoc.Password = "hello" but I get the same error.
Can this be done?
Thanks
Mark
I have a VB6 application that creates a mail merge document in Microsoft Word 2003. What I would like to do is either after the mail merge process is complete, password protect the document so no one can edit it or password protect the document before the mail merge, open the word document, enter the password so I can perform the mail merge then make sure that no one can edit the document.
Here is my code to open the document:
wrdDoc.MailMerge.OpenDataSource name:=App.Path & "\" & CurrentUser$ & "\mailmerge.xls", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source= App.Path & '\' & CurrentUser$ & '\mailmerge.xls';Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB

SQLStatement:="SELECT * FROM `Sheet1$`", SQLStatement1:="", SubType:=wdMergeSubTypeAccess
I tried entering a password in the passworddocument, passwordtemplate, writepassword, and writepasswordtemplage field but I keep getting a cannot open document because it is password protected. I also tried using wrdDoc.Password = "hello" but I get the same error.
Can this be done?
Thanks
Mark