Microsoft Word Page Numbering Part-Section-Page - vba

I have a long document with about 9 Parts and each part contains 2 - 5 sections. I want to have my page numbers read Part-Section-Page. For example, page 5 of section 4 in part 3 would have the page number 3-4-5.
Using this field code I can output this correct page number in my footer
{STYLEREF 1 \s}-{STYLEREF 2 \s}-{PAGE}
This works because the first field code outputs the current Part, signified by Header 1, the 2nd code outputs the section number signified by Header 2, and then last output is the page which I can control with section breaks.
BUT - This is no help with the Table of Contents! When the ToC is generated, Word only recognizes {PAGE} as the page number, and therefore I need to manually write the ToC.
Is there any way to make the page number actually be in the format x-y-x?
Any ideas or help would be appreciated!

Related

Continue page numbering from a specific section in MS Word?

How does one continue the page numbering from a specific section in MS Word?
Consider the following scenario:
MS Word document with 3 sections A, B, and C.
Page numbering starts at 1 on the first page of section A (ends at, let's say, 3, on page 3).
No page numbering (or alternate page numbering) in section B.
In section C, page numbering continues from that of section A (first page-number of section C is <last_page_A> + 1 = 4).
Now let the number pages in section A, B, and C vary and the page numbering
to automatically adapt. The document has a Table of Contents.
Is this possible using the MS Word GUI through some trickery I am not aware of? If not, how could one do this with MS Office Field Codes or VBA?
To my knowledge, the MS Word GUI only lets you continue page numbering from the previous section, or alternatively, lets you manually handle the page numberings:
To insert a page number cross-reference, follow these steps:
Insert a bookmark on the page containing the information you want to cross-reference.
Position the insertion point where you want the cross-reference to occur.
Press Ctrl+F9 to insert field brackets. Make sure the insertion point stays between the brackets.
Type pageref followed by the bookmark name used in step 1.
Press F9 to update the field information.
Please refer to the following link:
Inserting Page Number Cross-References
Controlling the Format of Cross-References

Word VBA detect blank pages after odd/even section break

I'm new here so be gentle... lol
I've made a document and have separated it into chapters (sections) and am numbering the pages of each section as follows
1-1 of 9
2-1 of 6
etc
I'm using odd page breaks to put the first page of my sections in my place of preference. Of course using odd/even page breaks will under the right circumstances result in a non-printing blank page at the end of the section which of course is exactly what is supposed to happen. The problem is that in those cases my page numbers end up as for example, 2-1 of 13 but 13 is a non printing blank page and so the last printing page is 2-12 of 13. I've tried .goto to that page but apparently it won't allow you to .goto that page. I pared down my code to just outputting the number of pages to a msgbox to prevent any ancillary nonsense from getting in the way of the point. Here it is:
Dim i, x
Dim FooterPages As Integer
Dim Sect As Integer
With ActiveDocument
For i = 1 To 10
'Footer page numbers
ActiveDocument.ActiveWindow.Selection.GoTo What:=wdGoToSection, Count:=i + 2
Sect = .ActiveWindow.Selection.Information(wdActiveEndSectionNumber)
FooterPages = .Sections(Sect).Range.Information(3) - .Sections(Sect - 1).Range.Information(3)
MsgBox FooterPages
Next i
End With
I would really appreciate some help with a bit of code to detect that last page so I can subtract it from the total page count of that section.
Thanks in advance

MS Access: Why is it not showing one record per report page?

I have a report with a header, body, and (blank) footer. I just want it to show the data corresponding to one record per page.
For example my record source has three rows, for example with Name and Comments.
I have the Name in the header, Comments in the body. For some reason it's trying to put the first two rows' Comments under the first Name header, and then the second page has the third Name with the third Comments.
I just want it to have
Page 1: Header 1 (first row's Name), Body 1 (first row's Comment)
Page 2: Header 2 (second row's Name), Body 2 (second row's Comment)
Page 3: Header 3 (third row's Name), Body 3 (third row's Comment)
and so on.
Why isn't it automatically constraining one row's data per report page?
It looks like what you actually want is to not use the Header or Footer, but instead put the Name and Comment together on the detail--you can expand this section to fit your report fields and format them as you want. Then in the properties of the detail section on the Format tab set the Force New Page property to After Section

VBA: Copy number from a string of text and insert into cells below

I want to create a makro in Excel which performs - after pressing a button - the below. I attached some dummy data that is formatted like the actual sheet.
There are several data blocks that are seperated by headlines in Sheet 1. From these headlines, I want to get a string of numbers and put it into column S for each line with data below that heading. In line 6 the heading says "2000", thus lines 8-19 should have a "2000" in column S and so on. The number I want to get is always after the word "Monthlyaccount" but the lenght of the number can be different - from 1 to 7 digits.
For lines where no data is given (data lines might be recognized by looking if in A is a valid date given) there should just be "ERR" instead of the number.
Can anyone help out?
Thanks so much upfront!
Say the string (in cell A1) contains "Monthlyaccount" followed by a blank followed by a number followed by another blank. To extract the number, use:
=--LEFT(MID(A1,FIND("Monthlyaccount",A1)+15,9999),-1+FIND(" ",MID(A1,FIND("Monthlyaccount",A1)+15,9999)))
This does as requested. Paste the following into S3 and drag down
=IF(AND(ISNUMBER(RIGHT(A2,4)*1),ISNUMBER(RIGHT(A3,4)*1)),S2,IF(ISNUMBER(RIGHT(A3,4)*1),LEFT(RIGHT(A1,LEN(A1)-FIND("Monthlyaccount",A1)-14),FIND(" ",RIGHT(A1,LEN(A1)-FIND("Monthlyaccount",A1)-14))),"ERR"))

Crystal Reports - Facilitating front/back printing

I have a single crystal report that usually ends up about 150 pages long. The single .rpt, through the use of clever grouping, actually includes records with little individual header and footer sections for each customer. Think of it as a sales report for 100 customers, each with their own section.
Each customer section is 2 to 7 pages in length.
We would like to print on the front and back of pages. However, my concern is that approximately half of the customer sections would begin printing on the back side of the last page of the previous customer section.
Edit: What this boils down to... I need to insert an extra page break if the current page number is odd. Any ideas?
well if all your asking for is a formula to insert a page break when page number is odd then add this to the New Page After or New Page Before formula on the desired Section of the report.
PageNumber Mod 2 = 1
Sorry I cant be of more help but Im having trouble understanding your question.
EDITED:
Thanks for the clarification
basically in your grouping for your customer (ie "little individual footer section"), you will need to do something like this in the New Page After formula
(Next({Customer.CustomerId}) <> {Customer.CustomerId})
AND
(PageNumber MOD 2 = 1)
Note Customer.CustomerID should reference a unique value for your customer in your recordset. I just made something up since I dont know your data field names. Basically the forumla above will look at the Next Unique Customer and if it is not the same value as the current customer, then you know that a new Customer section is starting. Combine that logic with weather or not the PageNumber is odd and you can tell weather or not you need to insert a page break.
EDITED 2
(ISNULL(Next({Customer.CustomerId})) OR Next({Customer.CustomerId}) = "")
AND
(Next({Customer.CustomerId}) <> {Customer.CustomerId})
AND
(PageNumber MOD 2 = 1)
You may want to check if Next Customer ID (IE Unique Customer Value) is null this way you dont end up with a blank page at the very end of the report.