Protect form fields in merged files

S

Smhall

Using the information from the amazing MVPs, I have created a document that
merges excel data into a document with form fields(that spell checks!!!).
I'm stuck on one last piece of the puzzle. I am trying to split the merged
document into individual files using a merge field as the user name. If the
merged document has the form proctection turned off, it works, but then all
the new documents are unprocted as well. Is there a way to keep the form
protection in my new documents?
 
D

Doug Robbins - Word MVP

After you create each individual document, use the command to protect it.

ActiveDocument.Protect wdAllowOnlyFormFields, NoReset

--
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
 
S

Smhall

Thanks for sending me in the right direction. I got it to work by putting 2
new commands in the "SplitMergeLetter" macro I copied from Graham Mayor's web
site. The first command unprotects the new document and the second command
re-protects it. I'm copying it here in case anyone in the future (who feels
WAY in over their heads) needs it:

Sub Splitter()
ActiveDocument.Unprotect
Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
Application.ScreenUpdating = False
With Selection
..HomeKey Unit:=wdStory
..EndKey Unit:=wdLine, Extend:=wdExtend
..MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
End With
sName = Selection
Docname = "c:\in process\merge\" & sName & ".doc"
ActiveDocument.Sections.First.Range.Cut
Documents.Add
With Selection
..Paste
..HomeKey Unit:=wdStory
..MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
..Delete
End With
ActiveDocument.Protect wdAllowOnlyFormFields, NoReset
ActiveDocument.SaveAs FileName:=Docname, _
FileFormat:=wdFormatDocument
ActiveWindow.Close
Counter = Counter + 1
Application.ScreenUpdating = True
Wend

End Sub

FYI: You need to change the Doc Name to a valid path and make sure the file
name is the VERY FIRST thing in the document
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top