xSiraX
asked on
Searching text in Word
I have a RTF-text coming out of a SAP-System. It consists of tables only.
I want to find a certain text, which is to be found from about 70 - 100 times (variable) and then delete this row and the three rows above. My question is, how to create e.g. a while-statement, that executes something till the text it searches for, can't be found any longer.
Thanks a lot for your answers!!
I want to find a certain text, which is to be found from about 70 - 100 times (variable) and then delete this row and the three rows above. My question is, how to create e.g. a while-statement, that executes something till the text it searches for, can't be found any longer.
Thanks a lot for your answers!!
To find something in a Text, try use the Instr function..
ASKER
I am able to find the text fragment. But I want Word to stop searching (and deleting the rows) when there's nothing left to find.
if your question is just about the while loop and how to search then its pretty easy.
you said you already have a text, so assuming that its not a file and you are having it in a string lets say S1.
so here is the sample for you
key_word="hi"
key_position=1
while key_position<>0
key_position = instr(key_position,s1,key_ word)
if key_position<>0 then
.
.
processing the string
.
key_position = key_position + 1
end if
wend
you said you already have a text, so assuming that its not a file and you are having it in a string lets say S1.
so here is the sample for you
key_word="hi"
key_position=1
while key_position<>0
key_position = instr(key_position,s1,key_
if key_position<>0 then
.
.
processing the string
.
key_position = key_position + 1
end if
wend
ASKER
Thanks for your answer
But it is a file (rtf), which contains one big table. And in some of the rows (70 - 100) there is one certain word. I want to find those rows and delete them as well as 3 rows above them.
But it is a file (rtf), which contains one big table. And in some of the rows (70 - 100) there is one certain word. I want to find those rows and delete them as well as 3 rows above them.
if your question is just about the while loop and how to search then its pretty easy.
you said you already have a text, so assuming that its not a file and you are having it in a string lets say S1.
so here is the sample for you
key_word="hi"
key_position=1
while key_position<>0
key_position = instr(key_position,s1,key_ word)
if key_position<>0 then
.
.
processing the string
.
key_position = key_position + 1
end if
wend
you said you already have a text, so assuming that its not a file and you are having it in a string lets say S1.
so here is the sample for you
key_word="hi"
key_position=1
while key_position<>0
key_position = instr(key_position,s1,key_
if key_position<>0 then
.
.
processing the string
.
key_position = key_position + 1
end if
wend
oops . plz ignore the msg. got repeated. seems there is no way i can update/delete my message.
anyways lets back to the post
if its a word file then probably My logic to delete the row and 3 rows above may not fit in to it, it could be done in text file but I'm not much sure about the word file containing table, and deleteing rows of the table.
you may take a look at WORD object
if its a word file then probably My logic to delete the row and 3 rows above may not fit in to it, it could be done in text file but I'm not much sure about the word file containing table, and deleteing rows of the table.
you may take a look at WORD object
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That's it!!!
nearly...
Thanks!
nearly...
Thanks!
Hi xSiraX,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept EDDYKT's comment(s) as an answer.
xSiraX, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept EDDYKT's comment(s) as an answer.
xSiraX, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
per recommendation
SpideyMod
Community Support Moderator @Experts Exchange
SpideyMod
Community Support Moderator @Experts Exchange