PDA

View Full Version : Syntax when looping through text entries



Nbisgaard
11-17-2016, 01:36 AM
Hey,

My code is currently:


soeg = "2016-11-18"repl = "2016-12-09"
'First search the main document using the Selection
With Selection.Find
.Text = soeg
.Replacement.Text = repl
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With

The code does a find and replace within a word document.
I would like to put "soeg" and "repl" into a loop so that i can run the find and replace multiple times.

So say i have:
soeg{1}="xx1", repl{1}="yy1" and soeg{2}="xx2", repl{2}="yy2", etc
And then i want to create a loop for soeg{i} and repl{i} to run through multiple find and replaces.

Whats the syntax in doing this?