I have a Word Document that automatically merges with data when it opens (Word document is called from a VB Application using the PrintIt() or ScreenIt() function.
However I would like to be sure that the document is protected immediately after it merges.
What is the best and securest way to do this?
____________________________________
Word Code is below:
____________________________________
Sub PrintIt()
'Call this macro if you want to merge to a printer
Call MergeIt(wdSendToPrinter)
End Sub
____________________________________
Sub PrintIt()
'Call this macro if you want to merge to a printer
Call MergeIt(wdSendToPrinter)
End Sub
____________________________________
Sub MergeIt(lDestination As Long)
'Actually executes the merge. You can't run it directly as
'you can't pass parameters to a macro
With ActiveDocument.MailMerge
.Destination = lDestination
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
On Error Resume Next
.Execute Pause:=True
On Error GoTo 0
End With
End Sub
However I would like to be sure that the document is protected immediately after it merges.
What is the best and securest way to do this?
____________________________________
Word Code is below:
____________________________________
Sub PrintIt()
'Call this macro if you want to merge to a printer
Call MergeIt(wdSendToPrinter)
End Sub
____________________________________
Sub PrintIt()
'Call this macro if you want to merge to a printer
Call MergeIt(wdSendToPrinter)
End Sub
____________________________________
Sub MergeIt(lDestination As Long)
'Actually executes the merge. You can't run it directly as
'you can't pass parameters to a macro
With ActiveDocument.MailMerge
.Destination = lDestination
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
On Error Resume Next
.Execute Pause:=True
On Error GoTo 0
End With
End Sub