View Single Post
  #8   Report Post  
AnttiK
 
Posts: n/a
Default

Hi Antti,

I assume you're working with Word 2003, since the formatting
restrictions first appeared in that version. The following method
works in all versions back to Word 2000 (maybe 97, I'm not sure)
because it doesn't depend on the restriction -- it's just that your
template will supply the only methods of changing the style in text
fields, and you supply only the styles you want.

When the form is protected, Word disables all methods of changing the
style, through dialogs, shortcuts, and VBA. The solution is to use VBA
to unprotect the document, change the style, and then restore the
protection, all in one operation.

You can place macros like these in your template (you may need to
change the names of the styles, as these aren't constant from one
language version to another). Also create toolbar buttons and/or
keyboard shortcuts to make it easy to call the macros.

Sub FieldStyleNormal()
Dim SaveRange As Range
Set SaveRange = Selection.Range
ActiveDocument.Unprotect
Selection.Paragraphs(1).Range.Style = _
ActiveDocument.Styles("Normal")
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
SaveRange.Select
End Sub

Sub FieldStyleHead1()
Dim SaveRange As Range
Set SaveRange = Selection.Range
ActiveDocument.Unprotect
Selection.Paragraphs(1).Range.Style = _
ActiveDocument.Styles("Heading 1")
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
SaveRange.Select
End Sub

Sub FieldStyleHead2()
Dim SaveRange As Range
Set SaveRange = Selection.Range
ActiveDocument.Unprotect
Selection.Paragraphs(1).Range.Style = _
ActiveDocument.Styles("Heading 2")
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
SaveRange.Select
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org


Hi Jay and Suzanne.

Thank you a lot for your answers. I'd like to try that way where I don't use
VBA. I don't have experience of VBA. Yes I know it's basic language, but
still I don't have time to learn it.

If you have this kind of problem, how you solve that without VBA? Is there a
way to limit useable styles, without protecting document? Can I lock only
some parts of document perhaps? I think the solution is very simple, but I
just don't get it.

Please help me a bit more...

-Antti