View Single Post
 
Old 08-23-2019, 05:37 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,166
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Since Greg's macro works by itself, you can choose an alternative approach to including it in your bigger macro - by using a pointer rather than the actual macro content.

Put Greg's macro in the same module as the larger macro. When you want Greg's macro to run, add a line in the bigger macro with the name of Greg's macro eg
Code:
Sub MyBigMacro()
  MsgBox "Working steps"
  ScratchMacro
  MsgBox "More working steps"
End Sub

Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
  Dim oRng As Range
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Text = "([a-z])(/)([a-z])"
    .MatchWildcards = True
    .Replacement.Text = "\1 \2 \3"
    .Execute Replace:=wdReplaceAll
  End With
lbl_Exit:
  Exit Sub
End Sub
If you step through that code, you can see that one macro runs a second macro. This is often used with Functions rather than Subs but the principle is the same.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote