D
Database Whiz Consulting
We have an application that creates protected Word documents by automating
Word with VBA and mail merge. All is good, application works as it should,
creates the documents just fine and all. Problem is, when the user opens the
file with Word 2003 or 2007 and prints the document (they are protected, so
they can't change them), the document still prompts the user if they want to
save the document. Behaviour does not occur with Word 2000, nor does it occur
with documents not created in this manner. Clearly Word thinks something is
changing when the user prints the file, but what? I've included part of the
Sub that generates the file:
Set wrdApp = CreateObject("Word.Application")
wrdApp.Documents.Open FileName:=strDoc, AddToRecentFiles:=False,
Visible:=True
wrdApp.Documents.Item(1).Activate
With wrdApp.Documents(strDoc).MailMerge
.DataSource.FirstRecord = 1
.DataSource.LastRecord = 1
.Destination = wdSendToNewDocument
.Execute
End With
wrdApp.Documents.Item(1).Activate
wrdApp.Documents.Item(1).Protect wdAllowOnlyComments
wrdApp.Documents.Item(1).SaveAs "C:\access\NAS\" & intHmnrID & "_" &
strDocName
wrdApp.Documents.Item(1).Close
wrdApp.Documents(strDoc).Close SaveChanges:=wdDoNotSaveChanges
wrdApp.Quit
Set wrdApp = Nothing
Word with VBA and mail merge. All is good, application works as it should,
creates the documents just fine and all. Problem is, when the user opens the
file with Word 2003 or 2007 and prints the document (they are protected, so
they can't change them), the document still prompts the user if they want to
save the document. Behaviour does not occur with Word 2000, nor does it occur
with documents not created in this manner. Clearly Word thinks something is
changing when the user prints the file, but what? I've included part of the
Sub that generates the file:
Set wrdApp = CreateObject("Word.Application")
wrdApp.Documents.Open FileName:=strDoc, AddToRecentFiles:=False,
Visible:=True
wrdApp.Documents.Item(1).Activate
With wrdApp.Documents(strDoc).MailMerge
.DataSource.FirstRecord = 1
.DataSource.LastRecord = 1
.Destination = wdSendToNewDocument
.Execute
End With
wrdApp.Documents.Item(1).Activate
wrdApp.Documents.Item(1).Protect wdAllowOnlyComments
wrdApp.Documents.Item(1).SaveAs "C:\access\NAS\" & intHmnrID & "_" &
strDocName
wrdApp.Documents.Item(1).Close
wrdApp.Documents(strDoc).Close SaveChanges:=wdDoNotSaveChanges
wrdApp.Quit
Set wrdApp = Nothing