![]() |
#4
|
||||
|
||||
![]()
Here is one approach. It assumes you have an "Answer" style in your document to apply to the correct answers. You can then have a secondary macro that toggles the "Answer" style as being same/different to the Normal style if you wanted to show or hide the answers.
Code:
Sub MarkAnswers() Dim lngPara As Long, iOffset As Integer, sAnswer As String For lngPara = 1 To ActiveDocument.Paragraphs.Count If Left(ActiveDocument.Paragraphs(lngPara).Range.Text, 5) = "Ans: " Then sAnswer = ActiveDocument.Paragraphs(lngPara).Range.Words(3) iOffset = Asc(sAnswer) - 69 Debug.Print lngPara, sAnswer, iOffset ActiveDocument.Paragraphs(lngPara + iOffset).Range.Style = "Answer" End If Next lngPara End Sub Sub ToggleAnswerShow() Dim aSty As Style With ActiveDocument.Styles("Answer") If .Font.Bold = ActiveDocument.Styles("Normal").Font.Bold Then .Font.Bold = True .Font.ColorIndex = wdGreen Else .Font = ActiveDocument.Styles("Normal").Font End If End With End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
RKS-P | Word | 12 | 09-30-2019 08:26 AM |
![]() |
chollyred | Excel | 1 | 08-26-2016 08:20 AM |
![]() |
rstrimel | Excel | 7 | 09-10-2014 07:54 AM |
![]() |
SteveBump | Excel | 5 | 10-29-2013 07:25 AM |
![]() |
imogul | Excel | 2 | 09-28-2011 04:11 AM |