Spell check work around

  • 15 April 2022
  • 2 replies
  • 57 views

Userlevel 4
Badge +2

All,

 

I know that spell check was an issue and last time I checked, there isn’t a solution inside ClickLearn.  That said, when your portal grows beyond 1,000 pages of content and steps, with multiple editors, it is easy to not catch misspelled words.  I will share my work around:

 

While working on a concordance file for my written processes (separate thread later), I am using a word frequency counter in VBA that counts the word frequency in my huge file.  From there, it is VERY easy to see the misspelled words in Word, go to your section in the written steps (the PDF of your training portal), find the specific recording, and then go update the recordings as necessary.   In this example, I have misspelled ‘separate’ 7 times, as found in VBA.

 

Before we go too far, don’t be afraid of this VBA, it’s easy and self-explanatory.  I also didn’t write it, found it on the Internet and works great.  When the script runs, for a 1,200 page doc, it took about 10 minutes to run.  Easy peasy.  When the script is done, it will create a new word doc and show you each word and the # of times it appears.  Misspelled words as you know are underlined in red.  

 

As I mentioned at the top of this post, I am working on a concordance file but found this quick tip and trick extremely useful for the spell check issue.

 

Steps:

 

  1. Make a copy of your Word doc; the “Full download portal” Word doc
  2. Open file and click on developer tab
  3. Create a new module in VBA, paste in code, run from top
    1. You can change the max word count if desired or leave as-is
    2. You can exclude words or leave as-is for first run
  4. Results will appear in 5-15 minutes in a new word doc
  5. Scan for misspelled words in frequency counts
  6. Go update your ClickLearn content as needed
  7. Reproduce your content

 

I hope you found this useful, VBA below.  Let me know if I can help.  Tom 😀

 

Sub WordFrequency()

    Const maxwords = 9000          'Maximum unique words allowed

    Dim SingleWord As String       'Raw word pulled from doc

    Dim Words(maxwords) As String  'Array to hold unique words

    Dim Freq(maxwords) As Integer  'Frequency counter for unique words

    Dim WordNum As Integer         'Number of unique words

    Dim ByFreq As Boolean          'Flag for sorting order

    Dim ttlwds As Long             'Total words in the document

    Dim Excludes As String         'Words to be excluded

    Dim Found As Boolean           'Temporary flag

    Dim j, k, l, Temp As Integer   'Temporary variables

    Dim ans As String              'How user wants to sort results

    Dim tword As String            '

 

    ' Set up excluded words

    Excludes = "[the][a][of][is][to][for][by][be][and][are]"

 

    ' Find out how to sort

    ByFreq = True

    ans = InputBox("Sort by WORD or by FREQ?", "Sort order", "WORD")

    If ans = "" Then End

    If UCase(ans) = "WORD" Then

        ByFreq = False

    End If

   

    Selection.HomeKey Unit:=wdStory

    System.Cursor = wdCursorWait

    WordNum = 0

    ttlwds = ActiveDocument.Words.Count

 

    ' Control the repeat

    For Each aword In ActiveDocument.Words

        SingleWord = Trim(LCase(aword))

        'Out of range?

        If SingleWord < "a" Or SingleWord > "z" Then

            SingleWord = ""

        End If

        'On exclude list?

        If InStr(Excludes, "[" & SingleWord & "]") Then

            SingleWord = ""

        End If

        If Len(SingleWord) > 0 Then

            Found = False

            For j = 1 To WordNum

                If Words(j) = SingleWord Then

                    Freq(j) = Freq(j) + 1

                    Found = True

                    Exit For

                End If

            Next j

            If Not Found Then

                WordNum = WordNum + 1

                Words(WordNum) = SingleWord

                Freq(WordNum) = 1

            End If

            If WordNum > maxwords - 1 Then

                j = MsgBox("Too many words.", vbOKOnly)

                Exit For

            End If

        End If

        ttlwds = ttlwds - 1

        StatusBar = "Remaining: " & ttlwds & ", Unique: " & WordNum

    Next aword

 

    ' Now sort it into word order

    For j = 1 To WordNum - 1

        k = j

        For l = j + 1 To WordNum

            If (Not ByFreq And Words(l) < Words(k)) _

              Or (ByFreq And Freq(l) > Freq(k)) Then k = l

        Next l

        If k <> j Then

            tword = Words(j)

            Words(j) = Words(k)

            Words(k) = tword

            Temp = Freq(j)

            Freq(j) = Freq(k)

            Freq(k) = Temp

        End If

        StatusBar = "Sorting: " & WordNum - j

    Next j

 

    ' Now write out the results

    tmpName = ActiveDocument.AttachedTemplate.FullName

    Documents.Add Template:=tmpName, NewTemplate:=False

    Selection.ParagraphFormat.TabStops.ClearAll

    With Selection

        For j = 1 To WordNum

            .TypeText Text:=Trim(Str(Freq(j))) _

              & vbTab & Words(j) & vbCrLf

        Next j

    End With

    System.Cursor = wdCursorNormal

    j = MsgBox("There were " & Trim(Str(WordNum)) & _

      " different words ", vbOKOnly, "Finished")

End Sub

 

 


2 replies

Userlevel 6
Badge

Hi @trice602 

 

Really cool script you have made here for the Word documents :)

 

For edited work instructions or text blocks in general, you can use the built in spell-checker in Attain:

An edited step with a typo

 

 

Userlevel 4
Badge +2

Thanks Morten!  Looking forward to moving to Attain!  That’s cool! 😀

Reply