PDA

View Full Version : Solved: Flicker when using custom spellchecker on protected document



OTWarrior
09-21-2007, 05:38 AM
I have modified some code from a spellchecker than can check form fields (I have changed it to run when you exit each form field, rather than checking everything)
However, it does slot of flickering when you run it, and I have to be careful of people with epilepsy in the work place.

I was wondering whta part of the code is causing it, I think it may be the turning on and off of the protection, but I don't know a way around it. The even weirder thing is it seems to go to the very first form field, and then to the one you are exiting to (ie, if you are in box3, and click box5, it will flicker as it goes to box1, then flicker as it goes to box5)

Public Sub proofing()
If Selection.FormFields.Count = 1 Then
'No textbox but a check- or listbox
BKMName0 = Selection.FormFields(1).Name
ResultCheck0 = ActiveDocument.FormFields(BKMName0).Result
ElseIf Selection.FormFields.Count = 0 And Selection.Bookmarks.Count > 0 Then
BKMName0 = Selection.Bookmarks(Selection.Bookmarks.Count).Name
ResultCheck0 = ActiveDocument.FormFields(BKMName0).Result
End If
ActiveDocument.FormFields(BKMName0).Range.NoProofing = False
End Sub
Public Sub SpellChqer()
If ActiveDocument.FormFields(BKMName0).Result = "" Then
Else
If ActiveDocument.ProtectionType <> wdNoProtection Then
bprotected = True
ActiveDocument.Unprotect Password:=""
End If

Set MyRange = ActiveDocument.FormFields(BKMName0).Range
MyRange.CheckSpelling
'ActiveDocument.FormFields(BKMName0).Range.CheckSpelling
'MyRange.CheckSpelling

If bprotected = True Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
End If
ActiveDocument.FormFields(BKMName0).Select
End Sub

Oorang
09-21-2007, 10:47 AM
I don't see anything in this code that will cause screen flicker. Did you post all of it? Usually screen flicker is caused by too-rapid updates to the screen. You can compensate for this by either turning off screenupdating at the beginning of a procedure and back on at the end, or by performing logical tests so that actions that cause a redraw only occur if they are going to cause an a screen change. (Example, some programs will update a statusbar or progress bar many times with increments smaller than will be displayed by the bar. This will cause flicker.)

OTWarrior
09-24-2007, 02:40 AM
its was :
ActiveDocument.FormFields(BKMName0).Range.NoProofing = False that was causing the flicker.

I still have flickering when I scroll up and down the page, but that is a different issue :rotlaugh: