View Single Post
 
Old 03-27-2014, 01:49 PM
Larry Sulky Larry Sulky is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Mar 2014
Posts: 14
Larry Sulky is on a distinguished road
Default

'Quick and dirty but it should do the job. You can build on it from here.
Code:
Sub ShowCorrectAnswer() 
     '
     ' ShowCorrectAnswer Macro
     '
    With Selection.Find 
        .Format = False 
        .MatchCase = True 
        .MatchWholeWord = False 
        .MatchWildcards = False 
        .MatchSoundsLike = False 
        .MatchAllWordForms = False 
    End With 
    Selection.HomeKey Unit:=wdStory 
    Do 
        Selection.Find.ClearFormatting 
        Selection.Find.Replacement.ClearFormatting 
        With Selection.Find 
            .Text = ") is correct." 
            .Replacement.Text = "} is correct." 
            .Forward = True 
            .Wrap = wdFindStop 
        End With 
        If Not Selection.Find.Execute(Replace:=wdReplaceOne) Then Goto Finish 
        Selection.Collapse direction:=wdCollapseStart 
        Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend 
        Selection.Copy 
        Selection.Find.ClearFormatting 
        Selection.Find.Replacement.ClearFormatting 
        With Selection.Find 
            .Text = "Answer (A)" 
            .Replacement.Text = "" 
            .Forward = False 
            .Wrap = wdFindAsk 
        End With 
        Selection.Find.Execute 
        Selection.Collapse direction:=wdCollapseStart 
        Selection.TypeText Text:="Answer: " 
        Selection.PasteAndFormat (wdFormatOriginalFormatting) 
        Selection.TypeParagraph 
    Loop 
Finish: 
    Selection.HomeKey Unit:=wdStory 
    Selection.Find.ClearFormatting 
    Selection.Find.Replacement.ClearFormatting 
    With Selection.Find 
        .Text = "} is correct." 
        .Replacement.Text = ") is correct." 
        .Forward = True 
        .Wrap = wdFindStop 
    End With 
    Selection.Find.Execute Replace:=wdReplaceAll 
End Sub

Last edited by macropod; 03-27-2014 at 04:45 PM. Reason: Added code tags & formatting
Reply With Quote