Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
dch3 dch3 is offline
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 2003 pulls up my mail merge template, but doesn't complete the merge into a new Form Letter 1 Sean Steele Mailmerge 1 April 12th 07 11:04 PM
Form password protection on mail merge documents Form Lady Microsoft Word Help 1 August 25th 06 08:52 AM
mail merge protection D. Jarrett Mailmerge 3 July 9th 06 03:06 PM
Take Mail Merge in Word back the the Mail Merge Helper 1,2,3 Form. Chris Green Mailmerge 5 October 8th 05 03:51 PM
Can I use a form template document for mail merge? Just Checking Mailmerge 1 December 14th 04 10:27 PM


All times are GMT +1. The time now is 09:17 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"