Spell checking VBA text box. (1 Viewer)

Spooky

Registered User.
Local time
Today, 08:42
Joined
Jun 11, 2012
Messages
18
Im trying to get a spell check into a word Userform application.It works just fine apart from one thing - there is no preview of the text being spell checked as below.




This is the code used:

Code:
Public Function FCN_Speel_Check()

    Dim oScratchPad As Word.Document
    Dim oRng As Word.Range
    Dim bChecked As Boolean

  If oScratchPad Is Nothing Then
    Set oScratchPad = Documents.Add(, , 1, False)
    oScratchPad.Windows.Add
    oScratchPad.Windows(2).Visible = False
  Else
  oScratchPad.Range.Delete
  End If

      If UF1.TextBox148.Value = "" Then
        bChecked = True
      Else
        Set oRng = oScratchPad.Range
        oRng = UF1.TextBox148.Text
        If Dialogs(wdDialogToolsSpellingAndGrammar).show = 0 Then
        bChecked = False
        End If
        oRng.End = oRng.End - 1
        bChecked = True
        UF1.TextBox148.Text = oRng.Text
      End If

    oScratchPad.Close wdDoNotSaveChanges
    Set oScratchPad = Nothing

    If bChecked Then
      MsgBox "Check complete"
    Else
      MsgBox "Spell checking was stopped in process."
    End If
    
lbl_Exit:
    Exit Function

End Function

Any clues as to why there is no preview or better code to use?
Thanks!
 

Spooky

Registered User.
Local time
Today, 08:42
Joined
Jun 11, 2012
Messages
18
I think I have found my own solution.
Using Application.ScreenUpdating = true whilst in the function fixes the problem
 

Users who are viewing this thread

Top Bottom