W
ward
Hello,
I use the command
SendKeys "^{h}"
to show the Find And Replace dialog box with some
predefined settings (see code below).
However, after some time of working (hours, ...) users
report that suddenly when they click the button that will
invoke the correct F&R action (and presents them with the
dialog box), the character preceding the cursor is
deleted. Or, if some text is selected at that moment, it
is deleted. Note that they didn't performed any action on
the F&R dialog box yet.
From then on, all documents that are open (or will be
opened), suffer from this behaviour. So Word has to be
closed and restarted.
I wouldn't believe them, if i had not seen and tried it
myself!
It might be important to note that - when this strange
behaviour starts - manually using CTRL-H to bring up te
F&R dialog works correctly (no charater is deleted, or
selected text is not replaced)
I can not reproduce this behaviour, it just seems to pop-
up after some undefined time of working.
Anybody knows what's happening? Can I use an other way
than Sendkeys to bring up the F&R dialog box?
Ward
----- CODE-----
Public Sub FRspaceComma()
'This is invoked by pressing a specific button on a toolbar
FindAndReplace " ,", ","
End Sub
Private Sub FindAndReplace(FindText As String, ReplaceText
As String, Optional DoFR As Boolean = False)
'Show F&R dialog box and if specified, execute F&R action
'Set F&R arguments
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = FindText
.Replacement.Text = ReplaceText
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
If DoFR Then
'execute F&R action
Selection.Find.Execute Replace:=wdReplaceAll
Else
'Show F&R dialog box
SendKeys "^{h}"
End If
End Sub
I use the command
SendKeys "^{h}"
to show the Find And Replace dialog box with some
predefined settings (see code below).
However, after some time of working (hours, ...) users
report that suddenly when they click the button that will
invoke the correct F&R action (and presents them with the
dialog box), the character preceding the cursor is
deleted. Or, if some text is selected at that moment, it
is deleted. Note that they didn't performed any action on
the F&R dialog box yet.
From then on, all documents that are open (or will be
opened), suffer from this behaviour. So Word has to be
closed and restarted.
I wouldn't believe them, if i had not seen and tried it
myself!
It might be important to note that - when this strange
behaviour starts - manually using CTRL-H to bring up te
F&R dialog works correctly (no charater is deleted, or
selected text is not replaced)
I can not reproduce this behaviour, it just seems to pop-
up after some undefined time of working.
Anybody knows what's happening? Can I use an other way
than Sendkeys to bring up the F&R dialog box?
Ward
----- CODE-----
Public Sub FRspaceComma()
'This is invoked by pressing a specific button on a toolbar
FindAndReplace " ,", ","
End Sub
Private Sub FindAndReplace(FindText As String, ReplaceText
As String, Optional DoFR As Boolean = False)
'Show F&R dialog box and if specified, execute F&R action
'Set F&R arguments
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = FindText
.Replacement.Text = ReplaceText
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
If DoFR Then
'execute F&R action
Selection.Find.Execute Replace:=wdReplaceAll
Else
'Show F&R dialog box
SendKeys "^{h}"
End If
End Sub