Log in

View Full Version : Insert SectionBreak from Coding in Excel



jazzyt2u
08-05-2008, 01:21 PM
Hi,

How do I insert a section break from excel after I have pasted a picture? Also how do I remove it if I don't need it.

The following isn't working:




Worksheets("DC1Chart").Range(rngT100, rng110).CopyPicture xlScreen, xlBitmapoDoc.Bookmarks("DownCompar1").Range.Select
oWord.Selection.PasteAndFormat Type:=wdFormatOriginalFormatting
oWord.InsertBreak Type:=wdSectionBreakNextPage




I also tried oDoc.InsertBreak Type:=wdSectionBreakNextPage

lucas
08-06-2008, 07:37 PM
maybe:

Selection.InsertBreak Type:=wdSectionBreakNextPage

a with statement for oWord might let you do all of the operations in one statement too.......not sure without seeing your document.

jazzyt2u
08-12-2008, 11:30 AM
Thank you.

Do you know how to select a certain header to change a word using oWord if I can get to the specific page using bookmarks?

jazzyt2u
08-13-2008, 10:02 AM
Hi Lucus,

I tried

oWord.Selection.InsertBreak Type:=wdSectionBreakNextPage

and it didn't work.

oDoc.Bookmarks("DemoTable").Range.Select
Worksheets("DemoTable").Range(rngTD130, rngTD140).CopyPicture xlScreen, xlBitmap
oWord.Selection.PasteAndFormat Type:=wdFormatOriginalFormatting
oWord.Selection.TypeParagraph
oWord.Selection.InsertBreak Type:=wdSectionBreakNextPage

I get the following error when it gets to the last line of code above:
Run-Time Error '9118':
Parameter value was out of acceptable range