Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New Page "Event" in a word document

Status
Not open for further replies.

oetkbyentc

Technical User
Apr 12, 2007
10
US
Im looking for a way to tell if a page has been added to a document being created by a macro, based on input from a user. I have tried the wbstatus.pages call but it stalls during macro execution and only updates randomly.

I need this functionality to add specific text to the top of the new page which is dependent in the current section of text being added. Headers dont allow for the formating required.

Any help would be greatly appreciated.
 
Both wdDialogFileSummaryInfo.Pages and wdDialogDocumentStatistics.pages fail to update as the document is being updated with new pages. If I run in debug mode and apply a break after each line is added they update ok and reflect the number of pages. This would be great if it only upated fast enough while the macro is running all out. I tried "DoEvents" within a timer but all this did was tie up even more process....
 



Code:
Set objPage = ActiveDocument. _
    ActiveWindow.Panes(1).Pages
msgbox objPage.count

Skip,

[glasses] [red][/red]
[tongue]
 
Thanks for the replies. Unfortunatly "Pages" does not seem to be a valid method in this case. I have searched quite a bit for a reference to "Page" and only seem to find it in th two rroutines I've already tried.
 
I have tried several iterations of the suggested code and get "method or data member not found" on the ".Pages" .

Does this code execute for you?

I'm using word2000 and MVB 6.3. Are you using the same versions?

 
Ahhhh...

Ty.
Such is the power in keeping current with Software....
 
Pages is new to 2003.

HOWEVER...is it not really a pages object. It still is completely dependent on the printer driver AND an up-to-date pagination.
I need this functionality to add specific text to the top of the new page which is dependent in the current section of text being added. Headers dont allow for the formating required.

I am going to have to press on this. Please explain:

1. "dependent in the current section". I have no idea wht you mean by this;

2. "headers don't allow for the formatting required". Huh? Header are wide open for any format you want. Please clarify.

Please also state exactly what is making the new page. Is this a explicit new page, or is there a new page because text has spilled past the current page, thus making a new page? Makes adifference.

How is the the text being put into the document?

WHY is text required at the top of a new page? What is the design requirement for this? If there is indeed a requiorement, then perhaps explicit page breaks would be part of the solution. Perhaps section breaks. Plus, I find it hard to accept that a header can not be formatted to fit your requirement.

Gerry
My paintings and sculpture
 
The new document is being built from input from a user. there are several sections and the length if each can very greatly. More over. If a portion of the section starts on one page and rolls into another the prtion on the preceding page needs to be move so that it all stays together.

The text is being added through the selection.typetext commands in a rather tight loop for each section.

as an example:

PC Alarms: Continued

No. Preset Current Description
001 1000 999 Lube Delay

The 1st 2 lines are section dependant
The 3rd and subsequent lines are data...
The 1st line naturaly would not have "Continued" if it was the 1st page of that section...

Another section.

PMC Alarms: Continued

2000 Lube Fault
Address: A0.0
Cause: "any number of lines
Remedy: "any number of lines"

Here's what I was looking to do:
If a new page was created during this part I wanted to finish the section then if possable get it all on one page. Now there could be 10 such parts. where 5 would fit then the 6th would roll onto a new page. the 6th I would want to move in its entirety to the 6th page..











 
Hi oetkbyentc,

For the page count you could try something based on:
Sub Test()
MsgBox ActiveDocument.ComputeStatistics(wdStatisticPages)
End Sub

However, for each 'section' (which I'm not sure is a Word Section), you might be better off checking the section heading's relative vertical position on the page, so that you can determine whether it's too close to the bottom of the page and, if so, format it with a 'page break before' setting.

Cheers

[MS MVP - Word]
 
Have a look at the WidowControl property.
I'm pretty sure Gerry will suggest some idea about Style ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top