Can't insert Continuous Break into the Word Document

U

UnkleVo

I am combining several documents into one.
In order to save each document's formating I am trying to insert
continuous breaks in the begining of each document but it fails.

The cursor seems to be sitting inside some frame or something.

I tried all possible options trying to move to the start of document
but with no luck.

When I manually move cursor to the regular text area the insert break
works fine.

Is there some kind of check I can do before inserting the break to
make sure that it will not fail or is there any areas of word doc
where it cannot be inserted.

Thank you.
 
D

Doug Robbins

The following inserts a continuous section break at the beginning of a
document for me:

Selection.HomeKey wdStory
Selection.InsertBreak Type:=wdSectionBreakContinuous


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
D

DA

If you're inside the header or a text frame, you cannot
insert the break.

To insert a break at the start of your document, you
could target the first paragraph (see example below).

-------------
Sub InsBreak()
Set myRange = ActiveDocument.Paragraphs(1).Range
With myRange
.Collapse Direction:=wdCollapseStart
.InsertBreak Type:=wdSectionBreakContinuous
End With
End Sub
 
U

UnkleVo

Thank you very much for all your responses.

Below is the code I am using for inserting a break.

activedocument.Unprotect Password:="MyPassword"
activedocument.Paragraphs(1).Range.Collapse direction:=wdCollapseStart
Word.Selection.InsertBreak Type:=wdSectionBreakContinuous


----- this is what I tried and it didn't work---
'activedocument.Range.GoTo what:=wdStory, which:=wdGoToFirst
'activedocument.Range.StartOf unit:=wdStory

'activedocument.Range.GoTo What:=wdLine, Which:=wdGoToFirst
'Word.Selection.GoTo What:=wdGoToLine, Which:=wdGoToRelative, Count:=5
'Word.Selection.MoveStart unit:=wdStory
'Word.Selection.HomeKey unit:=wdStory
'Word.Selection.GoTo what:=wdGoToSection, which:=wdGoToFirst

As you can see I tried to move to the first paragraph and it does move
to the first pragraph but only in the text area or footer.....


The problem I am having is that I can not get my cursor into position
where break can be inserted. For some reason when I try to go to the
start of the document it doesn't work.

May be there is a way to loop through the objects in doc and identify
which one is header and which one is not?



Thanks for all your help.
 
D

Doug Robbins

Try the code that I suggested.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
U

UnkleVo

I tried the code you suggested and it does not work for me.
It moves cursor to the first text area in the document and insert break still fails.
 
D

Doug Robbins

Send the document to me so that I can see what is going on. It definitely
inserts a break when I use it here.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 

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