Text replacing based on a true condition - Part II

H

Hari Prasadh

Hi,

I have a document running to 800 pages or so, which has been produced by
another software (WinCross - A CROSS-TABULATION Software) and its output was
saved in *.Rtf format. The another software itself generates

a) Table of contents --TOC
b) Actual Write-up after TOC
c) page numbers - on top and bottom of each page in b) (The first page
after TOC would have -- Page 1 -- on top right and bottom middle of each
page and the subsequent pages would have increasing page numbers)

Basically, the other software makes a), b) and c) as MAIN STORY. That is
page numbers which are there on each page after Table of contents are part
of the Main Story itself.

Due to some bug in Wincross we are producing outputs in batches and then
copy pasting them. That is b) is copied from each individual batch and
pasted one below the other to produce a consolidated/ global b). Due to copy
paste page numbers were wrong in the Global/Consolidated b). I got a macro
from H Weber recently which could realign the page numbers in b). Basically
this was a Find/replace text, where the text to find was -- .Text = "Page
[0-9]{1,2}" -- and text to replace was -- .Replacement.Text = "Page " &
lTmp - 30 , where lTmp is the real word page number. We are using the number
30 here because table of contents was for 30 pages.

Now, I seek a macro for correcting the page numbers which are displayed
WITHIN the TOCs.

Since, after running H Weber's macro, b) would be perfectly alright, so I
want page numbers within TOC to be displaying same page numbers as the
respective page numbers in b).

Im pasting part of the first Page of TOC.

Page 1.......TABLE 1-A
SCREENER


Page 45.......TABLE 1-B
QUOTA GROUPS


Page 64.......TABLE 1-C
REFORMULATED COMBINED QUOTA GROUPS


Page 73.......TABLE 1
COMBINED QUOTA GROUPS

So,What I want is to put a for loop which would search starting from first
Real page of word till the end of TOC. Then within each page of TOC it
searches for the string -- .text = "Page [0-9]{1,2,3}....." -- And then the
cursor goes to end of that and then reads the text of the remaining
sentence. Like in the above case -- Page 64.....-- would be searched and the
text of the remaining sentence would be -- TABLE 1-C --. Now, I want to
perform a search on text -- Table 1-C -- within b) part which is the part of
document after TOC. The Real word page number of the first instance of the
text would be copied and then it would replace -- Page 64.....-- with ---
Page ?? - 30 -- where ?? is the real page number where -- Table 1-C -- was
found within b).

Im doing - 30 in above case because I have taken an example where TOC is 30
pages. if it is different I will go and change that line of code to some
other number.

Please guide me if possible.

Thanks a lot,
Hari
India
 
H

Helmut Weber

Hi Hari,
are you talking about the built in word feature "table of content"?
Or is it just an ordinary table, or not even a table at all,
but some text called "table of contents"?

And besides that, I do my best, just like others here
and especially the fellow MVPs, but this may be
beyond of what can be handled in a newsgroup.

Do you see any way of making this doc accessible to us?

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
H

Hari Prasadh

Hi Helmut,

No this not a built in feature of word.

It's just some text called table of contents (and ur correct its not even a
table at all)

Would it be Ok if I attach this document to this newsgroup? I can strip out
all data and attach 8 or 9 pages of sample document to give an idea of what
I want. Please tell me if that would be fine.

(I see it as a For loop with 2 Nested If conditions inside, only problem is
I dont know the syntax and Word specific features - Use excel primarily)

Thanks a lot,
Hari
India
 
H

Helmut Weber

Hi Hari,
unfortunately, I think, most newsreaders
don't accept or do suppress attachments.

If you send me your doc, I'll have a look at it,
if I can find the time. Unlikely, though.

Use both addresses.
"red.sys" & chr(64) & "t-online.de"
"h.weber" & chr(64) & "mi-verlg.de"

Cheers

Helmut
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top