Incorporating 2 macros into 1 please

S

Steved

Hello from Steved

Dim i As Long, myrange As Range, j As Long
For i = 1 To ActiveDocument.Paragraphs.Count
j = InStr(ActiveDocument.Paragraphs(i).Range.Text, "=")
If j > 16 Then
Set myrange = ActiveDocument.Paragraphs(i).Range
myrange.End = myrange.Start + j - 1
myrange.Text = Left(myrange.Text, 15)
End If
Next i

Please how do I incorporate the above into the below macro.

Sub RaceDictionary()
Dim i As Long, pararange As Range
For i = 1 To ActiveDocument.Paragraphs.Count
Set pararange = ActiveDocument.Paragraphs(i).Range
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "'"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^$^$"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^$^$"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=2,
Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
.Text = "\(*by"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=2,
Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:="= "
Selection.EndKey Unit:=wdLine
Selection.TypeBackspace
Selection.TypeText Text:=", "
Selection.Find.ClearFormatting
With Selection.Find
.Text = "*$"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find.Font
.Size = 30
.Bold = True
End With
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Next i
End Sub

Thankyou.
 
J

Jeff

Steve

Don't be lazy! We are not telepathic - well most of us aren't :))

What are you trying to achieve by incorporating the two?
What is the purpose of each macro!
 
S

Steved

Hello From Steved

The Macro named RaceDictionary extracts information
from several lines of information to leave one line of
information. The other macro thens checks the line and if
the first word including spaces is greater than 15 it then
deletes to leave 15 including spaces before the = sign.

Ok at the the moment I'm runnining two macros on the same
document, and I was asking if the two can be combined to
run as one please.

Thankyou.
 
D

Doug Robbins

Trying to work out what RaceDictionary is doing would give me a terminal
headache. Try just inserting the code from the other macro I gave you at
the end of the RaceDictionary, between the Next i in RaceDictionary and the
End Sub.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
S

Steved

Hello Doug from Steved

It does what you designed it to do and it works very
nicely. Not to bad when you have no idea as to what the
objectives are.

Thankyou very much.

Have a nice weekend.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top