find and replace word count

T

Thejan Mendis

Hi All,

I just need to create a samll macro and i hope somebody can help me on this

i have few word documents and each one have "##" inside the text. i need
this ## to replace with counting order

like CHI01
CHI02
CHI03
.....
 
D

Dan

This should do it. The only reason I use the "testcountvar" is because I don't know of a way, as yet, to figure out the character length of a variable defined as an integer. It could be easily modified for three or four digit count numbers

Option Explici

Public Sub blah(
Dim countvar As Intege
Dim testcountvar As Strin
countvar =

D
With Selectio
With .Fin
.ClearFormattin
.MatchCase = Fals
.MatchWildcards = Fals
.Forward = Tru
.Wrap = wdFindContinu
.Text = "##
.Execut
End Wit
If .Find.Found = True The
countvar = countvar +
testcountvar = countva
.Delet
If Len(testcountvar) = 1 The
.TypeText "CHI0" & countva
ElseIf Len(testcountvar) > 1 The
.TypeText "CHI" & countva
End I
End I
End Wit
Loop Until Selection.Find.Found = Fals

End Su


----- Thejan Mendis wrote: ----

Hi All

I just need to create a samll macro and i hope somebody can help me on thi

i have few word documents and each one have "##" inside the text. i nee
this ## to replace with counting orde

like CHI0
CHI0
CHI0
....




#
CHI5


so on please help me on this.. please remember there is a string value an
integer. CHA+01==>CHA0

Thank
 
K

Klaus Linke

Hi Thejan,

Please also see the replies in the word97vba group.

And please cross-post messages instead of posting the same question to
several groups.
To do this, write one message, and add several newsgroups by clicking on
"Newsgroups:" in the header (as you seem to use OE).

(... Not that it's usually necessary to post to several different groups at
all, but if you think it's necessary, cross-posting is better)

Regards,
Klaus
 

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