Hi Greg,
is listarray an array filled with cell contents?
What is step 2 good for?
Process only each second entry?
Do you feed empty cells into the listarray?
Not that I think so, but can't think of something else either.
LBound and UBound?
Well, there must be a question behind the question!
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
>Hello Masters,
>
[quoted text clipped - 32 lines]
>but I don't really understand why or how it works. Thanks for any
>enlightenment you can offer.
Greg - 18 Mar 2005 18:08 GMT
Helmut
I have a macro that will perform a multiword find and replace operation
where the Find and Replace words are listed in a two column table
stored as a separate document. The Find words are listed on the left
under a column headed FIND. The Replace words on the right. These
words are used to build an array. Like this:
Set WordList = Documents.Open(fileName:="C:\Find and Replace List.doc")
ListArray = WordList.Tables(1).Range.Text
ListArray = Split(ListArray, Chr(13) & Chr(7))
WordList.Close
The Find and Replace code is:
For i = LBound(ListArray) To UBound(ListArray) - 1 Step 3
With rngstory.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ListArray(i)
.Replacement.Text = ListArray(i + 1)
.Execute Replace:=wdReplaceAll
End With
Next i
For the project I am playing with now, I only need FIND words and so I
adapted the code as I posted earlier. While experimenting with this I
noticed that if my text to be processes contains the word FIND (my
column header) then it is also processed which is what I don't want.
I guess what I am asking is how would you write the For i statement
such that it includes everything in the array except the first entry?
Thanks
Helmut Weber - 18 Mar 2005 18:19 GMT
Hi Greg,
For i = LBound(ListArray) + 1 To UBound(ListArray) - 1 Step 3
+ 1 ' !
Could that be all that is to it?
I must be missing the crucial point.
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Greg - 18 Mar 2005 18:47 GMT
Helmut,
Through trial and error I found that this will work to exclude the
header words Find and Replace:
For i = 3 To UBound(ListArray) - 1 Step 3
Helmut Weber - 18 Mar 2005 19:03 GMT
Hi Greg,
so it is Lbound + offset
where offset is NumberOfColumns.
By the way, I couldn't find a method to format
a table programmatically with a heading.
Not to speak of repeating headings in case of pagebreaks.
I wonder, what ListArray = WordList.Tables(1).Range.Text
will do in that case.
OT:
An uncle of mine has survived World War II as a submariner.
He's 80 + by now.
Really tough guy.
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Greg Maxey - 18 Mar 2005 23:33 GMT
Helmut,
Send an e-mail and we can chat about your uncle.

Signature
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
> Hi Greg,
> so it is Lbound + offset
[quoted text clipped - 18 lines]
> Word XP, Win 98
> http://word.mvps.org/
Helmut Weber - 18 Mar 2005 18:30 GMT
Hi Greg,
I see, hopefully.
That's new stuff to me.
I thought, maybe
>ListArray = WordList.Tables(1).Range.Text
>ListArray = Split(ListArray, Chr(13) & Chr(7))
would create a 2-dimensional array.
But it obviously doesn't.
So the offset would have to be equal to the number
of columns in the table, which is 2.
Or not?
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/