How do I add section breaks in VBA?

S

spovolny

I'm interested in having my entire document protected except for a
single word which I need the user to be able to edit a hyperlink. The
word is on its own line, so I put in a continuous section break before
and after the line, and then protected all of the document except
section 2 (which is the line with the word I need unprotected). This
seemed to work fine, but I don't know how to replicate it in code,
which I need to do. Can anyone help? Thanks alot,
Steve
 
D

Doug Robbins - Word MVP

Dim myrange As Range, myrange2 As Range
Set myrange = Selection.Range
Set myrange2 = myrange.Duplicate
myrange.InsertBreak wdSectionBreakContinuous
myrange2.Collapse wdCollapseEnd
myrange2.InsertBreak wdSectionBreakContinuous


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

Bear

Doug:

I almost "get" the Duplicate property for ranges, but it keeps slipping
away. Do you have any way to explain it so I'll understand better?

Bear
 
D

Doug Robbins - Word MVP

You set a duplicate range when you will be doing something to the original
range that will alter that range and then later want to perform another
operation on what was the original range.

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