PDA

View Full Version : Word - Access Text Replacement Help



ablajan
06-28-2005, 08:48 PM
Now I am making a text processing program using vba.
I connected word(2003) text document with accees(2003) database.
the program can find each word in text and replace it according to database.
But the problem is the speed is very low. it takes a lot of time.
another problem is that:
for example. in the sentence in text file :I have learned vba since 2004.
I build a words data (has about 2000 words LIKE LEARN) table and tails datatable (has about 1000 tails LIKE ED) in access database.
I want to make the string word+tail search through word text document, if it is found highlight or change colour or replace.
I made it a very simple way. but it takes a lot of time and never ends.
Couild you help me?
Thanks a lot.
ABLAJAN128 at HOTMAIL dot COM (ABLAJAN128@HOTMAIL.COM):hi:

mdmackillop
06-29-2005, 12:26 AM
Hi,
Welcome to VBA.
On the face of it, you must be doing 2,000,000 searches. Is this correct?

ablajan
06-29-2005, 03:06 AM
Yes, it is correct.some times it is more than the number.
Thank you for you quick responce.

mdmackillop
06-29-2005, 06:07 AM
I would suggest tackling it from the other end. It would seem more efficient to compare each word in the document with the database where length etc variables could be used to limit possibilities. I would also investigate ways of indexing the document words, depending upon the size of the document.

ablajan
06-29-2005, 06:25 AM
Thak you for your suggestion.
I could not find the solution when I make word+tails(from database) searching from the text in word document.
If it is searched one by one it takes five hours for 15000 times search.
My text document is about 500 pages or more than this.
Could you show an example of your suggestion?
Thank you for your consideration

mdmackillop
06-29-2005, 09:41 AM
I'm afraid Access is not one of my strong areas. It would take some planning of possible approaches, and I think the implementation is probably beyond my abilities. An interesting challenge for someone though.

MOS MASTER
06-29-2005, 10:17 AM
Hi & Welcome to VBAX! :hi:

Your query is not clear to me but you're doing a mass search & replace that's for shure. (I've coded several of those so I'm sure I've got some usefull code for the job..if we can fit it in)

You say your program takes ages to run..but we have not seen this program yet and I could imagine improvements could be made.

I would have used a extra word document with a simple table in it with my find and replace criteria. This would have cut out the access automation alltogether which is a big speed add to begin whit.

Would you be so kind to provide us with a stripped version of your database and dummy Word template. (Zipped as attachment)

I'm sure we can improve on the 5 hour execution time! :whistle:

ablajan
06-29-2005, 11:43 AM
It is a big search and replace.
I send you sample text and access file.
I have thousands of words in word table and tails in tail table.
my solution is search word+tails(one by one) from text one by one.
thank you for your suggestion.

ablajan
06-29-2005, 11:44 AM
and the text file

MOS MASTER
06-29-2005, 11:47 AM
Ok Thanks I'll look at it as soon as I can. (Have to make good on other promisses first) ;)

Later..:whistle:

MOS MASTER
06-29-2005, 11:51 AM
Ahums..the thing will be hard enough for me as is because It's using a different language then I'm on. (For understanding the words you're using)

But I've asked you for the code you are using to do the search & replace...there's no code here and I need that code to understand what you're doing so I can see if improvements can be made?

Without the code to start with I've got no clue what you need. :whistle:

ablajan
06-29-2005, 02:01 PM
The language is different.
I send you a sample in english in here.
eg:learn- learns learned learning
be- is are am was were been be ....etc
my code is:
dim x as string 'words as learn
dim y as string 'tails as s, ed, ing
dim z as string 'words in text
z= x+ y
if z=x+y then
replace z to x
end if
Thank you for your advice.
I want to solve it in a cycle

MOS MASTER
06-29-2005, 02:10 PM
Hi, :yes

I'm very sorry but that piece of code cannot perform a search and replace action in Word. (Let alone cycle through all variants in Access)

I just don't get it ......

I'll leave this to someone who understands the question. :(