Link to home
Start Free TrialLog in
Avatar of Andreas Hermle
Andreas HermleFlag for Germany

asked on

Counter for macro

Dear Experts:

below macro copies all parantheses at the end of the current document. To spruce this very handy macro up, I would like a counter integrated, that tells me via a MsgBox ...
... how many parenthetical expressions have been copied or in the case none were found
... no parentheses found in current document

Help is much appreciated. Thank you very much in advance.

Regards, Andreas


Sub CopyParentheticalExpressions()

Dim str As String
str = ""
   ActiveWindow.View.ShowFieldCodes = True

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
   Do While .Execute(findText:="\(*\)", MatchWildcards:=True, Forward:=True, Wrap:=wdFindStop) = True

ActiveWindow.View.ShowFieldCodes = True
        str = str & Selection.range.Text & vbCr
        Selection.Collapse wdCollapseEnd
    Loop
End With
ActiveDocument.range.InsertAfter str

ActiveWindow.View.ShowFieldCodes = False

End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

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
Avatar of Andreas Hermle

ASKER

Hi mbizup,

thank you very much for your professional help. It works! Regards, Andreas
> thank you very much

You are very welcome :)

I'm glad this worked for you.