View Single Post
 
Old 03-04-2014, 04:07 AM
RoMu RoMu is offline Windows 7 64bit Office 2010 32bit
Novice
 
Join Date: Mar 2014
Posts: 6
RoMu is on a distinguished road
Default Add Break at end of doc, control display of non-printable characters

Hello all,
using Office 2010, I have written a macro in VBA, which copies the table on first page (table is smaller than the page itself) to the second page.
The first table is being selected and copied by using the following commands (the macro is in Excel, controlling the Word application).

With appWord.ActiveDocument.Tables(1)
.Select
End With
appWord.Selection.Copy
appWord.Selection.EndKey Unit:=wdStory
appWord.Selection.InsertBreak Type:=wdSectionBreakNextPage
appWord.Selection.Paste

This works fine as long as the display of non-printing characters in Word is switched on. If this option is switched off, the break to the next page does not happen. In that case the pasted table splits between page one and two.

1. Is there a better way to make sure that the insertion of the break succeeds ?
2. Is there a way to switch the display of non-printing characters in Word on/off through VBA ?

Thanks Rolf
Reply With Quote