Link to home
Start Free TrialLog in
Avatar of BBaron
BBaron

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of tampabay420
tampabay420

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
Avatar of BBaron
BBaron

ASKER

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..
Avatar of BBaron

ASKER

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..
You should not close the question and ask the question here

?->