K
Keith
Like many users, I'm working on a Macro solution for spellchecking form field
contents in a protected document. The Word MVP site provides some excellent
suggestions at http://word.mvps.org/FAQs/MacrosVBA/SpellcheckProtectDoc.htm.
However, one issue briefly touched upon in this article is the fact that the
spell check dialog displays the protected text within the preview pane,
allowing users to modify protected text, or even delete the field object
itself.
The article above mentions a solution to this situation, where the contents
of each form field are moved to a "dummy document" and spellchecked there,
and the modified text is moved back into the original formfield.
I've implemented a solution that does this, and does it well. It creates a
non-visible instance of Word, which then launches spellchecker. However, I
have two problems with the way that this functions:
A) The spell check dialog is associated with a non-visible application, so
it has no button on the toolbar. If a user switches focus to another
application, they have no reliable way of navigating back to the spellchecker
other than alt+tabbing.
B) If the spell check dialog box is moved by a drag and drop, it leaves
ghost images on the screen and renders those sections of screen useless.
Both of these problems go away if I make my "dummy document" visible, but
overall this solution doesn't look as clean to the user. Does anyone have a
solution for the two issues above that would allow me to keep my dummy
document invisible? The following routine generates the dummy document and
spellchecks it:
Function CheckIsolatedText(ByVal strCheckText As String) As String
Dim objWord As Word.Application
Dim objDoc As Word.Document
Dim strOrigText As String
strOrigText = strCheckText
Set objWord = New Word.Application
With objWord
.Visible = False
Set objDoc = .Documents.Add
.Selection.Text = strCheckText
objDoc.CheckSpelling
strCheckText = .Selection.Text
objDoc.Close wdDoNotSaveChanges
Set objDoc = Nothing
.Quit wdDoNotSaveChanges
End With
Set objWord = Nothing
CheckIsolatedText = strCheckText
End Function
Thank you!
contents in a protected document. The Word MVP site provides some excellent
suggestions at http://word.mvps.org/FAQs/MacrosVBA/SpellcheckProtectDoc.htm.
However, one issue briefly touched upon in this article is the fact that the
spell check dialog displays the protected text within the preview pane,
allowing users to modify protected text, or even delete the field object
itself.
The article above mentions a solution to this situation, where the contents
of each form field are moved to a "dummy document" and spellchecked there,
and the modified text is moved back into the original formfield.
I've implemented a solution that does this, and does it well. It creates a
non-visible instance of Word, which then launches spellchecker. However, I
have two problems with the way that this functions:
A) The spell check dialog is associated with a non-visible application, so
it has no button on the toolbar. If a user switches focus to another
application, they have no reliable way of navigating back to the spellchecker
other than alt+tabbing.
B) If the spell check dialog box is moved by a drag and drop, it leaves
ghost images on the screen and renders those sections of screen useless.
Both of these problems go away if I make my "dummy document" visible, but
overall this solution doesn't look as clean to the user. Does anyone have a
solution for the two issues above that would allow me to keep my dummy
document invisible? The following routine generates the dummy document and
spellchecks it:
Function CheckIsolatedText(ByVal strCheckText As String) As String
Dim objWord As Word.Application
Dim objDoc As Word.Document
Dim strOrigText As String
strOrigText = strCheckText
Set objWord = New Word.Application
With objWord
.Visible = False
Set objDoc = .Documents.Add
.Selection.Text = strCheckText
objDoc.CheckSpelling
strCheckText = .Selection.Text
objDoc.Close wdDoNotSaveChanges
Set objDoc = Nothing
.Quit wdDoNotSaveChanges
End With
Set objWord = Nothing
CheckIsolatedText = strCheckText
End Function
Thank you!