tags:

views:

676

answers:

2

Is there a way to make a paragraph in a Microsoft Word 2003 document readonly using VBA?

+1  A: 

I think you can only do it by selecting the paragraphs that will not be protected.

Below is a sample macro that is selecting a piece of text, enabling it for editing, and then locking the rest of the document. You can either use IRM or password protection, the macro below is using the latter. You should replace the method of selection below by something more elegant

Selection.MoveLeft Unit:=wdCharacter, Count:=11, Extend:=wdExtend 
Selection.Editors.Add wdEditorEveryone
ActiveDocument.protect Password:="password", NoReset:=False, Type:= _
wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False
adilei
A: 

You might be able to do it by throwing the to-be-protected text into a text form and protecting that. Obviously a little gross.

Richard Campbell