[WORD2007] Is this possible and if so how?
Hi I am just starting to use VBA in Word
PROBLEM: I have a load of tags like [p.345] but now I want to add a page in and increment the hard coded page numbers by 1.
I know how to input the number and presume I could get for loop to start at 2000 and presumably work backwards, but am unsure how to change data..
Is this possible and if so any sample code ;) would be greatly appreciated
Re: [WORD2007] Is this possible and if so how?
are these page numbers? if so why are you not using pagenumber fields?
Re: [WORD2007] Is this possible and if so how?
Quote:
Originally Posted by
westconn1
are these page numbers?
YES
Quote:
Originally Posted by
westconn1
why are you not using pagenumber fields?
Because I dont know how to "Convert" them from [p.??] to what you said, the source document is utf-8 text with zero formatting, have a macro that does most of the formatting, so if theres an easy way please help if you are willing
Re: [WORD2007] Is this possible and if so how?
page numbering should be left to word!
nuff said!
here to grump!
Re: [WORD2007] Is this possible and if so how?
Hey don't be too hard on the guy. I used to have pages in large documents like this when I worked for insurance companies. Pages in these documents become their own entities and repagination would cause chaos. What we always did to add a page in those situations would be to add page 3A or something.
Word doesn't have a page object you can loop. What you could do is to loop through paragraphs and check for your page pattern... Forgive me I'm typing from memory and this is pseudocode.
Code:
Sub LoopParagraphs
Dim p as Paragraph
For each p in Activedocument.Paragraphs
If p.Range.Text Like "my pattern" Then
'Increment text in here
End If
Next
End Sub
Sorry I can't be more specific right now not enough time.
Re: [WORD2007] Is this possible and if so how?
as it is just text you could use a loop to replace each page number with +1
vb Code:
for i = lastpage to insrt step -1
' record a macro to find "[p." & i & "]" and replace with "[p. & i + 1 & "]"
next
where insrt is the page number position of the inserted page and lastpage speaks for itself
Re: [WORD2007] Is this possible and if so how?
Thanks all for the pointers..