MS Word Find/Replace Problem

Hi All,
I have a problem in that I am filling a word document with data from a database by replacing 'codes' with the data upon loading the word document. The problem that I have is that my documents are now very slow to open due to the fact that I am perfoming alot of find/replace procedures on the document, using the code below. Is there anyway of speeding up the find/replace procedure or any other suggestions on how we could replace codes in the document quicker?

many thanx for any help

Ben

myWordApp.Selection.find.ClearFormatting
myWordApp.Selection.find.replacement.ClearFormatting
    With myWordApp.Selection.find
        .Text = findtext
        .replacement.Text = replacetext
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
myWordApp.Selection.find.Execute Replace:=wdReplaceAll
BBaronAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tampabay420Commented:
you should use MS Word's Form Fields, this would be much easier... i'll post an example... if you need more detail on how to use MS Words Form Fields with VBA, just ask?

     bookmark1 = "FormField_NAME"
       If wdApp.ActiveDocument.Bookmarks.Exists(bookmark1) Then

        wdApp.ActiveDocument.FormFields(bookmark1).Range.Text = crfdata(i).value

       
       End If
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EDDYKTCommented:
I don't think your routine is slow because it is the fastest I can see. How many replaces you are going to do?

How long does it take?
If you command out this routine, will it speed up the time?
0
BBaronAuthor Commented:
Hi Guys,

thanx for the suggestion about the form fields tampabay420 Im going to investigate it a little more.. if you could perhaps email me on ben@brokerpartners.co.uk so I could ask more indepth questions and explain what Im doing a little me that would be great...

Eddykt,
the number of replaces depends on how many 'datacodes' I have in the template (user defined). so a basic document could be doing up to 100 finds..
It is definately the finds that is taking the time, I have traced it...
At some sites it can take up to a minute to open a word document and fill with data, so I obviously need to get it sorted..
0
BBaronAuthor Commented:
Hi Guys,

thanx for the suggestion about the form fields tampabay420 Im going to investigate it a little more.. if you could perhaps email me on ben@brokerpartners.co.uk so I could ask more indepth questions and explain what Im doing a little me that would be great...

Eddykt,
the number of replaces depends on how many 'datacodes' I have in the template (user defined). so a basic document could be doing up to 100 finds..
It is definately the finds that is taking the time, I have traced it...
At some sites it can take up to a minute to open a word document and fill with data, so I obviously need to get it sorted..
0
EDDYKTCommented:
You should not close the question and ask the question here

?->
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.