![]() |
#1
|
|||
|
|||
![]()
Hi everyone,
new to forum and word vba, and I very need help. I have to rearrange a doc file (composed by multiple sections) created by an application from a third party. I managed to resolve all the problems but pagenumbers in header, given in the form of "Page X of Y". I have to decide yet if maintaining the native page number format or change it. In the case I want to maintain the original format, my problem is that the Y is always of 1 minus than total page numbers (if I activate field codes, I get <NUMPAGES -1> and I can't manage to solve it with vba, that is a must). In the case I want to delete the native format "Page X of Y", I can remove "Page", "X" and "of", but not the same for "Y", which still remains: I've searched in a number of vba forums, but I found only the macro for deleting page numbers, that works for the "X" as I said, but not with the "Y"! These are the code I use for deleting "Page X of": Sub cancella() Dim objSect As Section Dim objHF As HeaderFooter Dim objPNum As PageNumber For Each objSect In ActiveDocument.Sections For Each objHF In objSect.Headers For Each objPNum In objHF.PageNumbers objPNum.Delete Next Next For Each objHF In objSect.Footers For Each objPNum In objHF.PageNumbers objPNum.Delete Next Next Next Call cancellare End Sub Sub cancellare() WordBasic.viewheaderonly Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "*" (the * is substitued by "Page" first and by"of" then, because if I use * as wildcard the macro deletes one char at time only): .Forward = True .Wrap = wdFindContinue .Format = False End With If Selection.Find.Execute Then With Selection Selection.Delete End With End If End Sub Very thanks in advance for the precious help!!! |
Tags |
page x of y |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
thefonebug | Word | 12 | 10-24-2016 05:18 AM |
How do I edit my TOC to reference the section numbers instead of the page numbers??? | mikey386 | Word | 0 | 12-17-2014 02:34 PM |
How do I refer to page numbers, when the numbers change as I prepare the document? | StevenD | Word | 5 | 11-29-2012 12:52 AM |
![]() |
goran | Word | 2 | 11-02-2012 03:42 PM |
![]() |
gracie5290 | Word | 1 | 02-02-2012 11:41 PM |