Please, can anyone help me with the shortcomings mentioned here about a "page-break" instruction in a Words document in a
code when running in Excel.
In addition, the normal code in Words for MoveUp" does not work, I want to get up into
an imported table with data and adjust the characteristics of the table in order to fit the page in Words.
in advance for kind assistance
This is my very first attempt to seek advice in programming VBA.
Background: XP professional, Office 2000
The context & the problem :
Running a long program in Excel
with many macros / coded subs in background.
The program will result in a lot of reports, typically of 5-25 pages each & with a lot of conditional text created in excel
macros / VBA
I want (must) get print out in Words as such printout is smoother.
Everything is - be the end of a lot of work - OK, except to make a page-break in the excel routine that runs what to be done
in the created word document.
Some instructions are OK, for example to rearrange margins, others, for example pagehead and pagefoot does not work, but
In words, the "instruction" for page break is - .InsertBreak Type:=wdPageBreak - to be put within With wrd (= stands for
Words..) and With .selection.
In words, it works, but when running from Excel, it does NOT work.
The code under Excel used for this small
program sequence is found below
' Open a document
Set wrd = GetObject(, "Word.Application"):
.TypeText Text:="This is page 1"
'.InsertBreak Type:=wdPageBreak ' tried - did not work
Type:=wdSectionBreakContinuous, ' tried - did not work
.TypeText Text:="Some text on page 2"
.Sections.Add ' this works, but text instructions after this command IS NOT placed after a page
' .MoveEndUntil Cset:="a ", Count:=wdForward, tried.... did not work
' .MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
.TypeText Text:="Here should be text, for example to state that we are now on page 2..."
Is it possible to have some help on this (trivial ??) matter ?