Consulting

Results 1 to 13 of 13

Thread: Word - Access Text Replacement Help

  1. #1
    VBAX Regular
    Joined
    Jun 2005
    Posts
    12
    Location

    Question Word - Access Text Replacement Help

    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
    Last edited by mdmackillop; 06-29-2005 at 12:22 AM. Reason: Email address modified

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi,
    Welcome to VBA.
    On the face of it, you must be doing 2,000,000 searches. Is this correct?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular
    Joined
    Jun 2005
    Posts
    12
    Location
    Yes, it is correct.some times it is more than the number.
    Thank you for you quick responce.

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    VBAX Regular
    Joined
    Jun 2005
    Posts
    12
    Location

    How can I do

    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

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7
    Administrator
    VP-Knowledge Base VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi & Welcome to VBAX!

    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!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  8. #8
    VBAX Regular
    Joined
    Jun 2005
    Posts
    12
    Location
    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.

  9. #9
    VBAX Regular
    Joined
    Jun 2005
    Posts
    12
    Location
    and the text file

  10. #10
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Ok Thanks I'll look at it as soon as I can. (Have to make good on other promisses first)

    Later..
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  11. #11
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    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.
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  12. #12
    VBAX Regular
    Joined
    Jun 2005
    Posts
    12
    Location
    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

  13. #13
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi,

    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.
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •