Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Protect Automated Word Merge Document

Status
Not open for further replies.

geoffreyg

Programmer
Dec 6, 2000
15
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top