-
Visual Basic Issue
I created a macro in order for any word being "Apple" to get switched with Tomato, Banana, Carrot or Melon. Yet the only words that are getting switched for, are the first two words which are Banana and Carrot. Why is this?
Sub ECHO()
Randomize
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormat…
With Selection.Find
Dim ltr As Variant
ltr = Array("Banana", "Carrot", "Melon", "Tomato")
x = 1
.Text = "Apple"
If x = 1 Then
.Replacement.Text = ltr(Rnd)
End If
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute replace:=wdReplaceAll
End Sub
'Im trying to build a macro that would help me at work. There is a lot of repetative stuff. I want to be able to run a macro that will open de document, edit the document with random stuff and print it on a specific time. I figure I start by randomizing some stuff that needs to be edited. If you guys believe this would be easier doing something else rather than VB let me know. I know little but I'm a quick learner. Thanks
-
Re: Visual Basic Issue
Have a look here on how to use the Rnd function properly :
http://www.vbforums.com/showthread.php?t=281172