Sort in Sections

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I created a document with some instructions in section 1. Created a section
2 to carry out the said instructions. Applied protection to section 1 to
prevent modification and left section 2 unprotected. When trying to sort data
in section 2 the sort function is grayed out. Is there a workaround for this?
This is a simple VCR tape list for an older person to keep their mind active,
we hope.
 
You will have to unlock the form sort the data then relock the form.
Something along the lines of

Sub SortTheForm()
Dim bProtected As Boolean
Dim sSection As Range
'Unprotect the file
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
Set sSection = ActiveDocument.Sections(2).Range
sSection.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs"
'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
End Sub

run from a toolbar button or on exit from a form field in section1 should do
the trick - http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Hi Graham,

Thanks for the information. Seems to me that it should be OK to do anything
in an unprotected section that would be acceptable in an unprotected
document. Apparently not.

I appreciate the reply and thanks for the code.
 
Back
Top