Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Using Form Protection with a Template for a Mail Merge
I'm creating a template for a mail merge and need to protect the form fields.
Obviously, the idea is to protect all of the text except for the form fields so that the user can't accidently change the key portions of the text. It appears that though a Word doesn't all a protected form to be used as a mail merge as the MAIL MERGE option remains greyed out until I unprotect the form. |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Using Form Protection with a Template for a Mail Merge
Yes the two features are not compatible, principally because formfields in a
protected document have bookmark names assigned to them and if you have them in a mail merge main document and you execute the merge to a new documents, you would end up with multiple instances of bookmarks with the same name. The following macro can be used to preserve bookmarks during a MailMerge ' Throwaway Macro created by Doug Robbins to "preserve" bookmarks during a MailMerge ' Dim abm As Bookmark, bmrange As Range, i As Long, Result As Document, j As Long, k As Long, linkrange As Range, linktarget As String Dim Source As Document Set Source = ActiveDocument i = 1 For j = 1 To Source.MailMerge.DataSource.RecordCount For Each abm In ActiveDocument.Range.Bookmarks System.PrivateProfileString("c:\bookmarks.txt", "bookmarkNames", "bookmark" & i) = abm.Name & Format(j) i = i + 1 Next Next j For Each abm In ActiveDocument.Range.Bookmarks abm.Range.InsertBefore "#" abm.Range.InsertAfter "#" Next With ActiveDocument.MailMerge .Destination = wdSendToNewDocument .Execute End With Set Result = ActiveDocument k = 1 Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=True, Wrap:=wdFindContinue, Forward:=True) = True Set bmrange = Selection.Range bmrange.Characters(bmrange.Characters.Count).Delet e bmrange.Characters(1).Delete Result.Bookmarks.Add System.PrivateProfileString("c:\bookmarks.txt", "bookmarkNames", "bookmark" & k), bmrange k = k + 1 Loop End With For i = 1 To Result.Hyperlinks.Count linktarget = Result.Hyperlinks(i).SubAddress Set linkrange = Result.Hyperlinks(i).Range linkrange.Select linktarget = linktarget & Format(Selection.Information(wdActiveEndSectionNum ber)) Result.Hyperlinks.Add Result.Hyperlinks(i).Range, "", linktarget Next i Source.Activate Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=True, Wrap:=wdFindContinue, Forward:=True) = True Set bmrange = Selection.Range bmrange.Characters(bmrange.Characters.Count).Delet e bmrange.Characters(1).Delete Loop End With However, as you probably want to end up with individual documents for each record in the data source, you may better off to use the addin that you can download from http://www.gmayor.com/individual_merge_letters.htm -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "dch3" wrote in message ... I'm creating a template for a mail merge and need to protect the form fields. Obviously, the idea is to protect all of the text except for the form fields so that the user can't accidently change the key portions of the text. It appears that though a Word doesn't all a protected form to be used as a mail merge as the MAIL MERGE option remains greyed out until I unprotect the form. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Word 2003 pulls up my mail merge template, but doesn't complete the merge into a new Form Letter 1 | Mailmerge | |||
Form password protection on mail merge documents | Microsoft Word Help | |||
mail merge protection | Mailmerge | |||
Take Mail Merge in Word back the the Mail Merge Helper 1,2,3 Form. | Mailmerge | |||
Can I use a form template document for mail merge? | Mailmerge |