Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I have a document with several form fields that in turn are assigned
bookmarks (e.g., PatientName), to allow automatic filling of the referenced fields. This works when the form is protected. However, when I attempted to use the following spell checking macro to check the contents of the form fields themselves (adapted from the macro written by contributed by Dave Rado, Bill Coan, and Astrid Zeelenberg on the MVP website, http://word.mvps.org/faqs/macrosvba/...ProtectDoc.htm) with the form protected, I end up LOSING THE BOOKMARK: Sub RunSpellcheck() Dim Cancelled As Boolean, MyRange As Range, _ CorrectedError As String, oDoc As Document Dim oSection As Section, OriginalRange As Range If Documents.Count = 0 Then Exit Sub End If Set oDoc = ActiveDocument Select Case oDoc.ProtectionType Case wdNoProtection, wdAllowOnlyRevisions If Options.CheckGrammarWithSpelling Then oDoc.CheckGrammar Else oDoc.CheckSpelling End If Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Exit Sub Case wdAllowOnlyComments Exit Sub End Select Set OriginalRange = Selection.Range System.Cursor = wdCursorWait oDoc.Unprotect oDoc.SpellingChecked = False StatusBar = "Spellchecking document..." For Each oSection In oDoc.Sections If oSection.ProtectedForForms Then Call CheckProtectedSection(oSection) If Cancelled Then Exit For End If Else If oSection.Range.SpellingErrors.Count 0 Then Application.ScreenUpdating = True oSection.Range.CheckSpelling If oSection.Range.SpellingErrors.Count 0 Then Exit For End If End If End If Next oSection oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True OriginalRange.Select Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.Range.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Cancelled = False CorrectedError = vbNullString Set MyRange = Nothing End Sub Private Sub CheckProtectedSection(oSection As Section) 'Checks ONLY the TEXT formfields but NOT listboxes or checkboxes. Dim FmFld As FormField, FmFldCount As Long, Pos As Long Application.ScreenUpdating = False For Each FmFld In oSection.Range.FormFields If FmFld.Type = wdFieldFormTextInput Then If FmFld.TextInput.Type = wdRegularText And FmFld.Enabled Then If Not Left$(Application.Version, 1) = "8" Then Call TurnNoProofingOff(FmFld) End If FmFld.Range.SpellingChecked = False FmFld.Range.LanguageID = wdEnglishUS If FmFld.Range.SpellingErrors.Count 0 Then If Left$(Application.Version, 1) = "8" _ And FmFld.Range.Paragraphs.Count 1 _ And FmFld.Range.Tables.Count 0 Then Call Word97TableBugWorkaround(FmFld) If Cancelled Then Exit Sub Else Set MyRange = FmFld.Range FmFldCount = oSection.Range.FormFields.Count Application.ScreenUpdating = True FmFld.Range.CheckSpelling If IsObjectValid(FmFld) Then If FmFld.Range.SpellingErrors.Count 0 Then Cancelled = True Exit Sub End If Else CorrectedError = MyRange.Text If Len(CorrectedError) = 0 Then CorrectedError = MyRange.Words(1).Text End If Pos = InStr(CorrectedError, vbTab) Do While Pos 0 CorrectedError = Mid$(CorrectedError, Pos + 1) Pos = InStr(CorrectedError, vbTab) Loop Do While Not FmFldCount = _ oSection.Range.FormFields.Count oDoc.Undo Loop If Selection.FormFields.Count = 0 Then Selection.MoveRight unit:=wdCharacter Selection.MoveLeft unit:=wdCharacter, Extend:=True End If If Not IsObjectValid(FmFld) Then Set FmFld = Selection.FormFields(1) End If FmFld.Result = CorrectedError End If End If Application.ScreenUpdating = False End If End If End If Next FmFld End Sub Private Sub TurnNoProofingOff(FmFld As FormField) 'This subroutine is called only in Word 2000 and above FmFld.Range.NoProofing = False End Sub Private Sub Word97TableBugWorkaround(FmFld As FormField) Set MyRange = FmFld.Range FmFld.Range.Fields(1).Unlink Application.ScreenUpdating = True MyRange.CheckSpelling If MyRange.SpellingErrors.Count 0 Then Cancelled = True End If CorrectedError = MyRange.Text Do While Not IsObjectValid(FmFld) oDoc.Undo Loop FmFld.Range.Fields(1).Result.Text = CorrectedError Application.ScreenUpdating = False End Sub That in turn causes the referenced fields to NOT work. Would anyone know the solution to this particular problem? Thanks. -- spassky |
#2
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
If your bookmarks are set in the formfield properties do you still have the
problem? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I have a document with several form fields that in turn are assigned bookmarks (e.g., PatientName), to allow automatic filling of the referenced fields. This works when the form is protected. However, when I attempted to use the following spell checking macro to check the contents of the form fields themselves (adapted from the macro written by contributed by Dave Rado, Bill Coan, and Astrid Zeelenberg on the MVP website, http://word.mvps.org/faqs/macrosvba/...ProtectDoc.htm) with the form protected, I end up LOSING THE BOOKMARK: Sub RunSpellcheck() Dim Cancelled As Boolean, MyRange As Range, _ CorrectedError As String, oDoc As Document Dim oSection As Section, OriginalRange As Range If Documents.Count = 0 Then Exit Sub End If Set oDoc = ActiveDocument Select Case oDoc.ProtectionType Case wdNoProtection, wdAllowOnlyRevisions If Options.CheckGrammarWithSpelling Then oDoc.CheckGrammar Else oDoc.CheckSpelling End If Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Exit Sub Case wdAllowOnlyComments Exit Sub End Select Set OriginalRange = Selection.Range System.Cursor = wdCursorWait oDoc.Unprotect oDoc.SpellingChecked = False StatusBar = "Spellchecking document..." For Each oSection In oDoc.Sections If oSection.ProtectedForForms Then Call CheckProtectedSection(oSection) If Cancelled Then Exit For End If Else If oSection.Range.SpellingErrors.Count 0 Then Application.ScreenUpdating = True oSection.Range.CheckSpelling If oSection.Range.SpellingErrors.Count 0 Then Exit For End If End If End If Next oSection oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True OriginalRange.Select Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.Range.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Cancelled = False CorrectedError = vbNullString Set MyRange = Nothing End Sub Private Sub CheckProtectedSection(oSection As Section) 'Checks ONLY the TEXT formfields but NOT listboxes or checkboxes. Dim FmFld As FormField, FmFldCount As Long, Pos As Long Application.ScreenUpdating = False For Each FmFld In oSection.Range.FormFields If FmFld.Type = wdFieldFormTextInput Then If FmFld.TextInput.Type = wdRegularText And FmFld.Enabled Then If Not Left$(Application.Version, 1) = "8" Then Call TurnNoProofingOff(FmFld) End If FmFld.Range.SpellingChecked = False FmFld.Range.LanguageID = wdEnglishUS If FmFld.Range.SpellingErrors.Count 0 Then If Left$(Application.Version, 1) = "8" _ And FmFld.Range.Paragraphs.Count 1 _ And FmFld.Range.Tables.Count 0 Then Call Word97TableBugWorkaround(FmFld) If Cancelled Then Exit Sub Else Set MyRange = FmFld.Range FmFldCount = oSection.Range.FormFields.Count Application.ScreenUpdating = True FmFld.Range.CheckSpelling If IsObjectValid(FmFld) Then If FmFld.Range.SpellingErrors.Count 0 Then Cancelled = True Exit Sub End If Else CorrectedError = MyRange.Text If Len(CorrectedError) = 0 Then CorrectedError = MyRange.Words(1).Text End If Pos = InStr(CorrectedError, vbTab) Do While Pos 0 CorrectedError = Mid$(CorrectedError, Pos + 1) Pos = InStr(CorrectedError, vbTab) Loop Do While Not FmFldCount = _ oSection.Range.FormFields.Count oDoc.Undo Loop If Selection.FormFields.Count = 0 Then Selection.MoveRight unit:=wdCharacter Selection.MoveLeft unit:=wdCharacter, Extend:=True End If If Not IsObjectValid(FmFld) Then Set FmFld = Selection.FormFields(1) End If FmFld.Result = CorrectedError End If End If Application.ScreenUpdating = False End If End If End If Next FmFld End Sub Private Sub TurnNoProofingOff(FmFld As FormField) 'This subroutine is called only in Word 2000 and above FmFld.Range.NoProofing = False End Sub Private Sub Word97TableBugWorkaround(FmFld As FormField) Set MyRange = FmFld.Range FmFld.Range.Fields(1).Unlink Application.ScreenUpdating = True MyRange.CheckSpelling If MyRange.SpellingErrors.Count 0 Then Cancelled = True End If CorrectedError = MyRange.Text Do While Not IsObjectValid(FmFld) oDoc.Undo Loop FmFld.Range.Fields(1).Result.Text = CorrectedError Application.ScreenUpdating = False End Sub That in turn causes the referenced fields to NOT work. Would anyone know the solution to this particular problem? Thanks. -- spassky |
#3
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Doing that only created 2 ADDITIONAL problems, namely (1) the bookmark is
destroyed after protecting the document, and (2) the reference field referring back to the bookmark no longer works. PERHAPS, I probably need someone to revise the macro (initially posted). -- spassky "Charles Kenyon" wrote: If your bookmarks are set in the formfield properties do you still have the problem? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I have a document with several form fields that in turn are assigned bookmarks (e.g., PatientName), to allow automatic filling of the referenced fields. This works when the form is protected. However, when I attempted to use the following spell checking macro to check the contents of the form fields themselves (adapted from the macro written by contributed by Dave Rado, Bill Coan, and Astrid Zeelenberg on the MVP website, http://word.mvps.org/faqs/macrosvba/...ProtectDoc.htm) with the form protected, I end up LOSING THE BOOKMARK: Sub RunSpellcheck() Dim Cancelled As Boolean, MyRange As Range, _ CorrectedError As String, oDoc As Document Dim oSection As Section, OriginalRange As Range If Documents.Count = 0 Then Exit Sub End If Set oDoc = ActiveDocument Select Case oDoc.ProtectionType Case wdNoProtection, wdAllowOnlyRevisions If Options.CheckGrammarWithSpelling Then oDoc.CheckGrammar Else oDoc.CheckSpelling End If Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Exit Sub Case wdAllowOnlyComments Exit Sub End Select Set OriginalRange = Selection.Range System.Cursor = wdCursorWait oDoc.Unprotect oDoc.SpellingChecked = False StatusBar = "Spellchecking document..." For Each oSection In oDoc.Sections If oSection.ProtectedForForms Then Call CheckProtectedSection(oSection) If Cancelled Then Exit For End If Else If oSection.Range.SpellingErrors.Count 0 Then Application.ScreenUpdating = True oSection.Range.CheckSpelling If oSection.Range.SpellingErrors.Count 0 Then Exit For End If End If End If Next oSection oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True OriginalRange.Select Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.Range.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Cancelled = False CorrectedError = vbNullString Set MyRange = Nothing End Sub Private Sub CheckProtectedSection(oSection As Section) 'Checks ONLY the TEXT formfields but NOT listboxes or checkboxes. Dim FmFld As FormField, FmFldCount As Long, Pos As Long Application.ScreenUpdating = False For Each FmFld In oSection.Range.FormFields If FmFld.Type = wdFieldFormTextInput Then If FmFld.TextInput.Type = wdRegularText And FmFld.Enabled Then If Not Left$(Application.Version, 1) = "8" Then Call TurnNoProofingOff(FmFld) End If FmFld.Range.SpellingChecked = False FmFld.Range.LanguageID = wdEnglishUS If FmFld.Range.SpellingErrors.Count 0 Then If Left$(Application.Version, 1) = "8" _ And FmFld.Range.Paragraphs.Count 1 _ And FmFld.Range.Tables.Count 0 Then Call Word97TableBugWorkaround(FmFld) If Cancelled Then Exit Sub Else Set MyRange = FmFld.Range FmFldCount = oSection.Range.FormFields.Count Application.ScreenUpdating = True FmFld.Range.CheckSpelling If IsObjectValid(FmFld) Then If FmFld.Range.SpellingErrors.Count 0 Then Cancelled = True Exit Sub End If Else CorrectedError = MyRange.Text If Len(CorrectedError) = 0 Then CorrectedError = MyRange.Words(1).Text End If Pos = InStr(CorrectedError, vbTab) Do While Pos 0 CorrectedError = Mid$(CorrectedError, Pos + 1) Pos = InStr(CorrectedError, vbTab) Loop Do While Not FmFldCount = _ oSection.Range.FormFields.Count oDoc.Undo Loop If Selection.FormFields.Count = 0 Then Selection.MoveRight unit:=wdCharacter Selection.MoveLeft unit:=wdCharacter, Extend:=True End If If Not IsObjectValid(FmFld) Then Set FmFld = Selection.FormFields(1) End If FmFld.Result = CorrectedError End If End If Application.ScreenUpdating = False End If End If End If Next FmFld End Sub Private Sub TurnNoProofingOff(FmFld As FormField) 'This subroutine is called only in Word 2000 and above FmFld.Range.NoProofing = False End Sub Private Sub Word97TableBugWorkaround(FmFld As FormField) Set MyRange = FmFld.Range FmFld.Range.Fields(1).Unlink Application.ScreenUpdating = True MyRange.CheckSpelling If MyRange.SpellingErrors.Count 0 Then Cancelled = True End If CorrectedError = MyRange.Text Do While Not IsObjectValid(FmFld) oDoc.Undo Loop FmFld.Range.Fields(1).Result.Text = CorrectedError Application.ScreenUpdating = False End Sub That in turn causes the referenced fields to NOT work. Would anyone know the solution to this particular problem? Thanks. -- spassky |
#4
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
What is wrong with using the original macro? What is your adaptation? What
is it supposed to do for you? (In case you haven't guessed, I didn't trace through your code. If you want someone to do that, I would suggest posting in one of the vba newsgroups rather than this one dealing with document management.) I can tell you that the one on the website has worked fine for me with numerous forms, both as a macro in the form template and as a macro in a global template. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... Doing that only created 2 ADDITIONAL problems, namely (1) the bookmark is destroyed after protecting the document, and (2) the reference field referring back to the bookmark no longer works. PERHAPS, I probably need someone to revise the macro (initially posted). -- spassky "Charles Kenyon" wrote: If your bookmarks are set in the formfield properties do you still have the problem? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I have a document with several form fields that in turn are assigned bookmarks (e.g., PatientName), to allow automatic filling of the referenced fields. This works when the form is protected. However, when I attempted to use the following spell checking macro to check the contents of the form fields themselves (adapted from the macro written by contributed by Dave Rado, Bill Coan, and Astrid Zeelenberg on the MVP website, http://word.mvps.org/faqs/macrosvba/...ProtectDoc.htm) with the form protected, I end up LOSING THE BOOKMARK: Sub RunSpellcheck() Dim Cancelled As Boolean, MyRange As Range, _ CorrectedError As String, oDoc As Document Dim oSection As Section, OriginalRange As Range If Documents.Count = 0 Then Exit Sub End If Set oDoc = ActiveDocument Select Case oDoc.ProtectionType Case wdNoProtection, wdAllowOnlyRevisions If Options.CheckGrammarWithSpelling Then oDoc.CheckGrammar Else oDoc.CheckSpelling End If Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Exit Sub Case wdAllowOnlyComments Exit Sub End Select Set OriginalRange = Selection.Range System.Cursor = wdCursorWait oDoc.Unprotect oDoc.SpellingChecked = False StatusBar = "Spellchecking document..." For Each oSection In oDoc.Sections If oSection.ProtectedForForms Then Call CheckProtectedSection(oSection) If Cancelled Then Exit For End If Else If oSection.Range.SpellingErrors.Count 0 Then Application.ScreenUpdating = True oSection.Range.CheckSpelling If oSection.Range.SpellingErrors.Count 0 Then Exit For End If End If End If Next oSection oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True OriginalRange.Select Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.Range.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Cancelled = False CorrectedError = vbNullString Set MyRange = Nothing End Sub Private Sub CheckProtectedSection(oSection As Section) 'Checks ONLY the TEXT formfields but NOT listboxes or checkboxes. Dim FmFld As FormField, FmFldCount As Long, Pos As Long Application.ScreenUpdating = False For Each FmFld In oSection.Range.FormFields If FmFld.Type = wdFieldFormTextInput Then If FmFld.TextInput.Type = wdRegularText And FmFld.Enabled Then If Not Left$(Application.Version, 1) = "8" Then Call TurnNoProofingOff(FmFld) End If FmFld.Range.SpellingChecked = False FmFld.Range.LanguageID = wdEnglishUS If FmFld.Range.SpellingErrors.Count 0 Then If Left$(Application.Version, 1) = "8" _ And FmFld.Range.Paragraphs.Count 1 _ And FmFld.Range.Tables.Count 0 Then Call Word97TableBugWorkaround(FmFld) If Cancelled Then Exit Sub Else Set MyRange = FmFld.Range FmFldCount = oSection.Range.FormFields.Count Application.ScreenUpdating = True FmFld.Range.CheckSpelling If IsObjectValid(FmFld) Then If FmFld.Range.SpellingErrors.Count 0 Then Cancelled = True Exit Sub End If Else CorrectedError = MyRange.Text If Len(CorrectedError) = 0 Then CorrectedError = MyRange.Words(1).Text End If Pos = InStr(CorrectedError, vbTab) Do While Pos 0 CorrectedError = Mid$(CorrectedError, Pos + 1) Pos = InStr(CorrectedError, vbTab) Loop Do While Not FmFldCount = _ oSection.Range.FormFields.Count oDoc.Undo Loop If Selection.FormFields.Count = 0 Then Selection.MoveRight unit:=wdCharacter Selection.MoveLeft unit:=wdCharacter, Extend:=True End If If Not IsObjectValid(FmFld) Then Set FmFld = Selection.FormFields(1) End If FmFld.Result = CorrectedError End If End If Application.ScreenUpdating = False End If End If End If Next FmFld End Sub Private Sub TurnNoProofingOff(FmFld As FormField) 'This subroutine is called only in Word 2000 and above FmFld.Range.NoProofing = False End Sub Private Sub Word97TableBugWorkaround(FmFld As FormField) Set MyRange = FmFld.Range FmFld.Range.Fields(1).Unlink Application.ScreenUpdating = True MyRange.CheckSpelling If MyRange.SpellingErrors.Count 0 Then Cancelled = True End If CorrectedError = MyRange.Text Do While Not IsObjectValid(FmFld) oDoc.Undo Loop FmFld.Range.Fields(1).Result.Text = CorrectedError Application.ScreenUpdating = False End Sub That in turn causes the referenced fields to NOT work. Would anyone know the solution to this particular problem? Thanks. -- spassky |
#5
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I wish I could share with you one custom document I had created with numerous
form fields, referenced (REF) fields, and bookmarks. So, I will attempt to describe how my form works, short of sending one as an attachment. The document is a actually a template for a physical examination form utilized by the Department of Transportation, containing fields for the individuals name (bookmarked PatientName), address (bookmarked Address), State (bookmarked State), examiners name (bookmarked Examiner), etc. The exam findings, as well as the individuals personal information, are entered into the protected form fields manually. There is a certificate at the end of the exam, with the individuals name, address, state, zip code, examiners name, etc. As these are redundant information, my form automatically will complete it with the information already entered in the earlier form fields. As the relevant form fields have already been bookmarked, the referenced fields on the certificate are automatically updated accordingly. I have tested the form such that it would do this, even when completely protected, so I can reuse the form over and over. Lets say on the form just described, I misspelled Detroit in the protected form field. I would then like to run a macro to check for such misspelling. I came close, using the macro provided, but then I ran into my current problem. By the way, I am running Word 2000, running on Windows XP Professional or Windows 2000 Professional. Thanks, once again. -- spassky "Charles Kenyon" wrote: What is wrong with using the original macro? What is your adaptation? What is it supposed to do for you? (In case you haven't guessed, I didn't trace through your code. If you want someone to do that, I would suggest posting in one of the vba newsgroups rather than this one dealing with document management.) I can tell you that the one on the website has worked fine for me with numerous forms, both as a macro in the form template and as a macro in a global template. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... Doing that only created 2 ADDITIONAL problems, namely (1) the bookmark is destroyed after protecting the document, and (2) the reference field referring back to the bookmark no longer works. PERHAPS, I probably need someone to revise the macro (initially posted). -- spassky "Charles Kenyon" wrote: If your bookmarks are set in the formfield properties do you still have the problem? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I have a document with several form fields that in turn are assigned bookmarks (e.g., PatientName), to allow automatic filling of the referenced fields. This works when the form is protected. However, when I attempted to use the following spell checking macro to check the contents of the form fields themselves (adapted from the macro written by contributed by Dave Rado, Bill Coan, and Astrid Zeelenberg on the MVP website, http://word.mvps.org/faqs/macrosvba/...ProtectDoc.htm) with the form protected, I end up LOSING THE BOOKMARK: Sub RunSpellcheck() Dim Cancelled As Boolean, MyRange As Range, _ CorrectedError As String, oDoc As Document Dim oSection As Section, OriginalRange As Range If Documents.Count = 0 Then Exit Sub End If Set oDoc = ActiveDocument Select Case oDoc.ProtectionType Case wdNoProtection, wdAllowOnlyRevisions If Options.CheckGrammarWithSpelling Then oDoc.CheckGrammar Else oDoc.CheckSpelling End If Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Exit Sub Case wdAllowOnlyComments Exit Sub End Select Set OriginalRange = Selection.Range System.Cursor = wdCursorWait oDoc.Unprotect oDoc.SpellingChecked = False StatusBar = "Spellchecking document..." For Each oSection In oDoc.Sections If oSection.ProtectedForForms Then Call CheckProtectedSection(oSection) If Cancelled Then Exit For End If Else If oSection.Range.SpellingErrors.Count 0 Then Application.ScreenUpdating = True oSection.Range.CheckSpelling If oSection.Range.SpellingErrors.Count 0 Then Exit For End If End If End If Next oSection oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True OriginalRange.Select Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.Range.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Cancelled = False CorrectedError = vbNullString Set MyRange = Nothing End Sub Private Sub CheckProtectedSection(oSection As Section) 'Checks ONLY the TEXT formfields but NOT listboxes or checkboxes. Dim FmFld As FormField, FmFldCount As Long, Pos As Long Application.ScreenUpdating = False For Each FmFld In oSection.Range.FormFields If FmFld.Type = wdFieldFormTextInput Then If FmFld.TextInput.Type = wdRegularText And FmFld.Enabled Then If Not Left$(Application.Version, 1) = "8" Then Call TurnNoProofingOff(FmFld) End If FmFld.Range.SpellingChecked = False FmFld.Range.LanguageID = wdEnglishUS If FmFld.Range.SpellingErrors.Count 0 Then If Left$(Application.Version, 1) = "8" _ And FmFld.Range.Paragraphs.Count 1 _ And FmFld.Range.Tables.Count 0 Then Call Word97TableBugWorkaround(FmFld) If Cancelled Then Exit Sub Else Set MyRange = FmFld.Range FmFldCount = oSection.Range.FormFields.Count Application.ScreenUpdating = True FmFld.Range.CheckSpelling If IsObjectValid(FmFld) Then If FmFld.Range.SpellingErrors.Count 0 Then Cancelled = True Exit Sub End If Else CorrectedError = MyRange.Text If Len(CorrectedError) = 0 Then CorrectedError = MyRange.Words(1).Text End If Pos = InStr(CorrectedError, vbTab) Do While Pos 0 CorrectedError = Mid$(CorrectedError, Pos + 1) Pos = InStr(CorrectedError, vbTab) Loop Do While Not FmFldCount = _ oSection.Range.FormFields.Count oDoc.Undo Loop If Selection.FormFields.Count = 0 Then Selection.MoveRight unit:=wdCharacter Selection.MoveLeft unit:=wdCharacter, Extend:=True End If If Not IsObjectValid(FmFld) Then Set FmFld = Selection.FormFields(1) End If FmFld.Result = CorrectedError End If End If Application.ScreenUpdating = False End If End If End If Next FmFld End Sub Private Sub TurnNoProofingOff(FmFld As FormField) 'This subroutine is called only in Word 2000 and above FmFld.Range.NoProofing = False End Sub Private Sub Word97TableBugWorkaround(FmFld As FormField) Set MyRange = FmFld.Range FmFld.Range.Fields(1).Unlink Application.ScreenUpdating = True MyRange.CheckSpelling If MyRange.SpellingErrors.Count 0 Then Cancelled = True End If CorrectedError = MyRange.Text Do While Not IsObjectValid(FmFld) oDoc.Undo Loop FmFld.Range.Fields(1).Result.Text = CorrectedError Application.ScreenUpdating = False End Sub That in turn causes the referenced fields to NOT work. Would anyone know the solution to this particular problem? Thanks. -- spassky |
#6
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
In my testing, using the macro that is provided on the Word MVP website does
not destroy the bookmarks that are assigned either automatically or manually to the formfields via the formfield properties dialog or by using InsertBookmark. If however the spelling of a work in a referenced formfield is corrected, the cross reference is updated. If you insert the following lines of code oDoc.PrintPreview oDoc.ClosePrintPreview before the line oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True the cross references will be updated. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "jarimura" wrote in message ... I wish I could share with you one custom document I had created with numerous form fields, referenced (REF) fields, and bookmarks. So, I will attempt to describe how my form works, short of sending one as an attachment. The document is a actually a template for a physical examination form utilized by the Department of Transportation, containing fields for the individual's name (bookmarked "PatientName"), address (bookmarked "Address"), State (bookmarked "State"), examiner's name (bookmarked "Examiner"), etc. The exam findings, as well as the individual's personal information, are entered into the protected form fields manually. There is a certificate at the end of the exam, with the individual's name, address, state, zip code, examiner's name, etc. As these are redundant information, my form automatically will complete it with the information already entered in the earlier form fields. As the relevant form fields have already been bookmarked, the referenced fields on the certificate are automatically updated accordingly. I have tested the form such that it would do this, even when completely protected, so I can reuse the form over and over. Let's say on the form just described, I misspelled "Detroit" in the protected form field. I would then like to run a macro to check for such misspelling. I came close, using the macro provided, but then I ran into my current problem. By the way, I am running Word 2000, running on Windows XP Professional or Windows 2000 Professional. Thanks, once again. -- spassky "Charles Kenyon" wrote: What is wrong with using the original macro? What is your adaptation? What is it supposed to do for you? (In case you haven't guessed, I didn't trace through your code. If you want someone to do that, I would suggest posting in one of the vba newsgroups rather than this one dealing with document management.) I can tell you that the one on the website has worked fine for me with numerous forms, both as a macro in the form template and as a macro in a global template. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... Doing that only created 2 ADDITIONAL problems, namely (1) the bookmark is destroyed after protecting the document, and (2) the reference field referring back to the bookmark no longer works. PERHAPS, I probably need someone to revise the macro (initially posted). -- spassky "Charles Kenyon" wrote: If your bookmarks are set in the formfield properties do you still have the problem? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I have a document with several form fields that in turn are assigned bookmarks (e.g., PatientName), to allow automatic filling of the referenced fields. This works when the form is protected. However, when I attempted to use the following spell checking macro to check the contents of the form fields themselves (adapted from the macro written by contributed by Dave Rado, Bill Coan, and Astrid Zeelenberg on the MVP website, http://word.mvps.org/faqs/macrosvba/...ProtectDoc.htm) with the form protected, I end up LOSING THE BOOKMARK: Sub RunSpellcheck() Dim Cancelled As Boolean, MyRange As Range, _ CorrectedError As String, oDoc As Document Dim oSection As Section, OriginalRange As Range If Documents.Count = 0 Then Exit Sub End If Set oDoc = ActiveDocument Select Case oDoc.ProtectionType Case wdNoProtection, wdAllowOnlyRevisions If Options.CheckGrammarWithSpelling Then oDoc.CheckGrammar Else oDoc.CheckSpelling End If Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Exit Sub Case wdAllowOnlyComments Exit Sub End Select Set OriginalRange = Selection.Range System.Cursor = wdCursorWait oDoc.Unprotect oDoc.SpellingChecked = False StatusBar = "Spellchecking document..." For Each oSection In oDoc.Sections If oSection.ProtectedForForms Then Call CheckProtectedSection(oSection) If Cancelled Then Exit For End If Else If oSection.Range.SpellingErrors.Count 0 Then Application.ScreenUpdating = True oSection.Range.CheckSpelling If oSection.Range.SpellingErrors.Count 0 Then Exit For End If End If End If Next oSection oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True OriginalRange.Select Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.Range.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Cancelled = False CorrectedError = vbNullString Set MyRange = Nothing End Sub Private Sub CheckProtectedSection(oSection As Section) 'Checks ONLY the TEXT formfields but NOT listboxes or checkboxes. Dim FmFld As FormField, FmFldCount As Long, Pos As Long Application.ScreenUpdating = False For Each FmFld In oSection.Range.FormFields If FmFld.Type = wdFieldFormTextInput Then If FmFld.TextInput.Type = wdRegularText And FmFld.Enabled Then If Not Left$(Application.Version, 1) = "8" Then Call TurnNoProofingOff(FmFld) End If FmFld.Range.SpellingChecked = False FmFld.Range.LanguageID = wdEnglishUS If FmFld.Range.SpellingErrors.Count 0 Then If Left$(Application.Version, 1) = "8" _ And FmFld.Range.Paragraphs.Count 1 _ And FmFld.Range.Tables.Count 0 Then Call Word97TableBugWorkaround(FmFld) If Cancelled Then Exit Sub Else Set MyRange = FmFld.Range FmFldCount = oSection.Range.FormFields.Count Application.ScreenUpdating = True FmFld.Range.CheckSpelling If IsObjectValid(FmFld) Then If FmFld.Range.SpellingErrors.Count 0 Then Cancelled = True Exit Sub End If Else CorrectedError = MyRange.Text If Len(CorrectedError) = 0 Then CorrectedError = MyRange.Words(1).Text End If Pos = InStr(CorrectedError, vbTab) Do While Pos 0 CorrectedError = Mid$(CorrectedError, Pos + 1) Pos = InStr(CorrectedError, vbTab) Loop Do While Not FmFldCount = _ oSection.Range.FormFields.Count oDoc.Undo Loop If Selection.FormFields.Count = 0 Then Selection.MoveRight unit:=wdCharacter Selection.MoveLeft unit:=wdCharacter, Extend:=True End If If Not IsObjectValid(FmFld) Then Set FmFld = Selection.FormFields(1) End If FmFld.Result = CorrectedError End If End If Application.ScreenUpdating = False End If End If End If Next FmFld End Sub Private Sub TurnNoProofingOff(FmFld As FormField) 'This subroutine is called only in Word 2000 and above FmFld.Range.NoProofing = False End Sub Private Sub Word97TableBugWorkaround(FmFld As FormField) Set MyRange = FmFld.Range FmFld.Range.Fields(1).Unlink Application.ScreenUpdating = True MyRange.CheckSpelling If MyRange.SpellingErrors.Count 0 Then Cancelled = True End If CorrectedError = MyRange.Text Do While Not IsObjectValid(FmFld) oDoc.Undo Loop FmFld.Range.Fields(1).Result.Text = CorrectedError Application.ScreenUpdating = False End Sub That in turn causes the referenced fields to NOT work. Would anyone know the solution to this particular problem? Thanks. -- spassky |
#7
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I tried to insert the code as you recommended. However, I am still running
into a problem, whenever the form field is filled in using only ONE word, e.g., Detroit in the form field bookmarked City, for instance. Lets say I misspelled Detroit dtrr. When I run the macro, it will recognize the error, and the view box Spelling: English (U.S.) will appear, apparently not only highlighting the misspelled word, but also the immediately adjacent BOOKMARK BRACKETS. When I double click on the error in the view box to select the ENTIRE word, not only is the misspelled word itself highlighted but also the immediately adjacent BOOKMARK BRACKETS as well. When I proceed to input the correction, the corrected word (in this instance, Detroit is inserted into the document, but at the same time the bookmark itself is destroyed. So now the referenced field will no longer have bookmark referenced to, and I get a Run-time 424 error. I hope this clarifies the difficulty I am experiencing. Thanks. -- spassky "Doug Robbins - Word MVP" wrote: In my testing, using the macro that is provided on the Word MVP website does not destroy the bookmarks that are assigned either automatically or manually to the formfields via the formfield properties dialog or by using InsertBookmark. If however the spelling of a work in a referenced formfield is corrected, the cross reference is updated. If you insert the following lines of code oDoc.PrintPreview oDoc.ClosePrintPreview before the line oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True the cross references will be updated. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "jarimura" wrote in message ... I wish I could share with you one custom document I had created with numerous form fields, referenced (REF) fields, and bookmarks. So, I will attempt to describe how my form works, short of sending one as an attachment. The document is a actually a template for a physical examination form utilized by the Department of Transportation, containing fields for the individual's name (bookmarked "PatientName"), address (bookmarked "Address"), State (bookmarked "State"), examiner's name (bookmarked "Examiner"), etc. The exam findings, as well as the individual's personal information, are entered into the protected form fields manually. There is a certificate at the end of the exam, with the individual's name, address, state, zip code, examiner's name, etc. As these are redundant information, my form automatically will complete it with the information already entered in the earlier form fields. As the relevant form fields have already been bookmarked, the referenced fields on the certificate are automatically updated accordingly. I have tested the form such that it would do this, even when completely protected, so I can reuse the form over and over. Let's say on the form just described, I misspelled "Detroit" in the protected form field. I would then like to run a macro to check for such misspelling. I came close, using the macro provided, but then I ran into my current problem. By the way, I am running Word 2000, running on Windows XP Professional or Windows 2000 Professional. Thanks, once again. -- spassky "Charles Kenyon" wrote: What is wrong with using the original macro? What is your adaptation? What is it supposed to do for you? (In case you haven't guessed, I didn't trace through your code. If you want someone to do that, I would suggest posting in one of the vba newsgroups rather than this one dealing with document management.) I can tell you that the one on the website has worked fine for me with numerous forms, both as a macro in the form template and as a macro in a global template. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... Doing that only created 2 ADDITIONAL problems, namely (1) the bookmark is destroyed after protecting the document, and (2) the reference field referring back to the bookmark no longer works. PERHAPS, I probably need someone to revise the macro (initially posted). -- spassky "Charles Kenyon" wrote: If your bookmarks are set in the formfield properties do you still have the problem? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I have a document with several form fields that in turn are assigned bookmarks (e.g., PatientName), to allow automatic filling of the referenced fields. This works when the form is protected. However, when I attempted to use the following spell checking macro to check the contents of the form fields themselves (adapted from the macro written by contributed by Dave Rado, Bill Coan, and Astrid Zeelenberg on the MVP website, http://word.mvps.org/faqs/macrosvba/...ProtectDoc.htm) with the form protected, I end up LOSING THE BOOKMARK: Sub RunSpellcheck() Dim Cancelled As Boolean, MyRange As Range, _ CorrectedError As String, oDoc As Document Dim oSection As Section, OriginalRange As Range If Documents.Count = 0 Then Exit Sub End If Set oDoc = ActiveDocument Select Case oDoc.ProtectionType Case wdNoProtection, wdAllowOnlyRevisions If Options.CheckGrammarWithSpelling Then oDoc.CheckGrammar Else oDoc.CheckSpelling End If Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Exit Sub Case wdAllowOnlyComments Exit Sub End Select Set OriginalRange = Selection.Range System.Cursor = wdCursorWait oDoc.Unprotect oDoc.SpellingChecked = False StatusBar = "Spellchecking document..." For Each oSection In oDoc.Sections If oSection.ProtectedForForms Then Call CheckProtectedSection(oSection) If Cancelled Then Exit For End If Else If oSection.Range.SpellingErrors.Count 0 Then Application.ScreenUpdating = True oSection.Range.CheckSpelling If oSection.Range.SpellingErrors.Count 0 Then Exit For End If End If End If Next oSection oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True OriginalRange.Select Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.Range.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Cancelled = False CorrectedError = vbNullString Set MyRange = Nothing End Sub Private Sub CheckProtectedSection(oSection As Section) 'Checks ONLY the TEXT formfields but NOT listboxes or checkboxes. Dim FmFld As FormField, FmFldCount As Long, Pos As Long Application.ScreenUpdating = False For Each FmFld In oSection.Range.FormFields If FmFld.Type = wdFieldFormTextInput Then If FmFld.TextInput.Type = wdRegularText And FmFld.Enabled Then If Not Left$(Application.Version, 1) = "8" Then Call TurnNoProofingOff(FmFld) End If FmFld.Range.SpellingChecked = False FmFld.Range.LanguageID = wdEnglishUS If FmFld.Range.SpellingErrors.Count 0 Then If Left$(Application.Version, 1) = "8" _ And FmFld.Range.Paragraphs.Count 1 _ And FmFld.Range.Tables.Count 0 Then Call Word97TableBugWorkaround(FmFld) If Cancelled Then Exit Sub Else Set MyRange = FmFld.Range FmFldCount = oSection.Range.FormFields.Count Application.ScreenUpdating = True FmFld.Range.CheckSpelling If IsObjectValid(FmFld) Then If FmFld.Range.SpellingErrors.Count 0 Then Cancelled = True Exit Sub End If Else CorrectedError = MyRange.Text If Len(CorrectedError) = 0 Then CorrectedError = MyRange.Words(1).Text End If Pos = InStr(CorrectedError, vbTab) Do While Pos 0 CorrectedError = Mid$(CorrectedError, Pos + 1) Pos = InStr(CorrectedError, vbTab) Loop Do While Not FmFldCount = _ oSection.Range.FormFields.Count oDoc.Undo Loop If Selection.FormFields.Count = 0 Then Selection.MoveRight unit:=wdCharacter Selection.MoveLeft unit:=wdCharacter, Extend:=True End If If Not IsObjectValid(FmFld) Then Set FmFld = Selection.FormFields(1) End If FmFld.Result = CorrectedError End If End If Application.ScreenUpdating = False End If End If End If Next FmFld End Sub Private Sub TurnNoProofingOff(FmFld As FormField) 'This subroutine is called only in Word 2000 and above FmFld.Range.NoProofing = False End Sub Private Sub Word97TableBugWorkaround(FmFld As FormField) Set MyRange = FmFld.Range FmFld.Range.Fields(1).Unlink Application.ScreenUpdating = True MyRange.CheckSpelling If MyRange.SpellingErrors.Count 0 Then Cancelled = True End If CorrectedError = MyRange.Text Do While Not IsObjectValid(FmFld) oDoc.Undo Loop FmFld.Range.Fields(1).Result.Text = CorrectedError Application.ScreenUpdating = False End Sub That in turn causes the referenced fields to NOT work. Would anyone know the solution to this particular problem? |
#8
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I tried to insert the code as you recommended. However, I am still running
into a problem, whenever the form field is filled in using only ONE word, e.g., Detroit in the form field bookmarked City, for instance. Lets say I misspelled Detroit dtrr. When I run the macro, it will recognize the error, and the view box Spelling: English (U.S.) will appear, apparently not only highlighting the misspelled word, but also the immediately adjacent BOOKMARK BRACKETS. When I double click on the error in the view box to select the ENTIRE word, not only is the misspelled word itself highlighted but also the immediately adjacent BOOKMARK BRACKETS as well. When I proceed to input the correction, the corrected word (in this instance, Detroit is inserted into the document, but at the same time the bookmark itself is destroyed. So now the referenced field will no longer have bookmark referenced to, and I get a Run-time 424 error. I hope this clarifies the difficulty I am experiencing. Thanks. -- spassky "Doug Robbins - Word MVP" wrote: In my testing, using the macro that is provided on the Word MVP website does not destroy the bookmarks that are assigned either automatically or manually to the formfields via the formfield properties dialog or by using InsertBookmark. If however the spelling of a work in a referenced formfield is corrected, the cross reference is updated. If you insert the following lines of code oDoc.PrintPreview oDoc.ClosePrintPreview before the line oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True the cross references will be updated. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "jarimura" wrote in message ... I wish I could share with you one custom document I had created with numerous form fields, referenced (REF) fields, and bookmarks. So, I will attempt to describe how my form works, short of sending one as an attachment. The document is a actually a template for a physical examination form utilized by the Department of Transportation, containing fields for the individual's name (bookmarked "PatientName"), address (bookmarked "Address"), State (bookmarked "State"), examiner's name (bookmarked "Examiner"), etc. The exam findings, as well as the individual's personal information, are entered into the protected form fields manually. There is a certificate at the end of the exam, with the individual's name, address, state, zip code, examiner's name, etc. As these are redundant information, my form automatically will complete it with the information already entered in the earlier form fields. As the relevant form fields have already been bookmarked, the referenced fields on the certificate are automatically updated accordingly. I have tested the form such that it would do this, even when completely protected, so I can reuse the form over and over. Let's say on the form just described, I misspelled "Detroit" in the protected form field. I would then like to run a macro to check for such misspelling. I came close, using the macro provided, but then I ran into my current problem. By the way, I am running Word 2000, running on Windows XP Professional or Windows 2000 Professional. Thanks, once again. -- spassky "Charles Kenyon" wrote: What is wrong with using the original macro? What is your adaptation? What is it supposed to do for you? (In case you haven't guessed, I didn't trace through your code. If you want someone to do that, I would suggest posting in one of the vba newsgroups rather than this one dealing with document management.) I can tell you that the one on the website has worked fine for me with numerous forms, both as a macro in the form template and as a macro in a global template. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... Doing that only created 2 ADDITIONAL problems, namely (1) the bookmark is destroyed after protecting the document, and (2) the reference field referring back to the bookmark no longer works. PERHAPS, I probably need someone to revise the macro (initially posted). -- spassky "Charles Kenyon" wrote: If your bookmarks are set in the formfield properties do you still have the problem? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I have a document with several form fields that in turn are assigned bookmarks (e.g., PatientName), to allow automatic filling of the referenced fields. This works when the form is protected. However, when I attempted to use the following spell checking macro to check the contents of the form fields themselves (adapted from the macro written by contributed by Dave Rado, Bill Coan, and Astrid Zeelenberg on the MVP website, http://word.mvps.org/faqs/macrosvba/...ProtectDoc.htm) with the form protected, I end up LOSING THE BOOKMARK: Sub RunSpellcheck() Dim Cancelled As Boolean, MyRange As Range, _ CorrectedError As String, oDoc As Document Dim oSection As Section, OriginalRange As Range If Documents.Count = 0 Then Exit Sub End If Set oDoc = ActiveDocument Select Case oDoc.ProtectionType Case wdNoProtection, wdAllowOnlyRevisions If Options.CheckGrammarWithSpelling Then oDoc.CheckGrammar Else oDoc.CheckSpelling End If Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Exit Sub Case wdAllowOnlyComments Exit Sub End Select Set OriginalRange = Selection.Range System.Cursor = wdCursorWait oDoc.Unprotect oDoc.SpellingChecked = False StatusBar = "Spellchecking document..." For Each oSection In oDoc.Sections If oSection.ProtectedForForms Then Call CheckProtectedSection(oSection) If Cancelled Then Exit For End If Else If oSection.Range.SpellingErrors.Count 0 Then Application.ScreenUpdating = True oSection.Range.CheckSpelling If oSection.Range.SpellingErrors.Count 0 Then Exit For End If End If End If Next oSection oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True OriginalRange.Select Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.Range.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Cancelled = False CorrectedError = vbNullString Set MyRange = Nothing End Sub Private Sub CheckProtectedSection(oSection As Section) 'Checks ONLY the TEXT formfields but NOT listboxes or checkboxes. Dim FmFld As FormField, FmFldCount As Long, Pos As Long Application.ScreenUpdating = False For Each FmFld In oSection.Range.FormFields If FmFld.Type = wdFieldFormTextInput Then If FmFld.TextInput.Type = wdRegularText And FmFld.Enabled Then If Not Left$(Application.Version, 1) = "8" Then Call TurnNoProofingOff(FmFld) End If FmFld.Range.SpellingChecked = False FmFld.Range.LanguageID = wdEnglishUS If FmFld.Range.SpellingErrors.Count 0 Then If Left$(Application.Version, 1) = "8" _ And FmFld.Range.Paragraphs.Count 1 _ And FmFld.Range.Tables.Count 0 Then Call Word97TableBugWorkaround(FmFld) If Cancelled Then Exit Sub Else Set MyRange = FmFld.Range FmFldCount = oSection.Range.FormFields.Count Application.ScreenUpdating = True FmFld.Range.CheckSpelling If IsObjectValid(FmFld) Then If FmFld.Range.SpellingErrors.Count 0 Then Cancelled = True Exit Sub End If Else CorrectedError = MyRange.Text If Len(CorrectedError) = 0 Then CorrectedError = MyRange.Words(1).Text End If Pos = InStr(CorrectedError, vbTab) Do While Pos 0 CorrectedError = Mid$(CorrectedError, Pos + 1) Pos = InStr(CorrectedError, vbTab) Loop Do While Not FmFldCount = _ oSection.Range.FormFields.Count oDoc.Undo Loop If Selection.FormFields.Count = 0 Then Selection.MoveRight unit:=wdCharacter Selection.MoveLeft unit:=wdCharacter, Extend:=True End If If Not IsObjectValid(FmFld) Then Set FmFld = Selection.FormFields(1) End If FmFld.Result = CorrectedError End If End If Application.ScreenUpdating = False End If End If End If Next FmFld End Sub Private Sub TurnNoProofingOff(FmFld As FormField) 'This subroutine is called only in Word 2000 and above FmFld.Range.NoProofing = False End Sub Private Sub Word97TableBugWorkaround(FmFld As FormField) Set MyRange = FmFld.Range FmFld.Range.Fields(1).Unlink Application.ScreenUpdating = True MyRange.CheckSpelling If MyRange.SpellingErrors.Count 0 Then Cancelled = True End If CorrectedError = MyRange.Text Do While Not IsObjectValid(FmFld) oDoc.Undo Loop FmFld.Range.Fields(1).Result.Text = CorrectedError Application.ScreenUpdating = False End Sub That in turn causes the referenced fields to NOT work. Would anyone know the solution to this particular problem? |
#9
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I would like to ADD the following to my most recent reply. Not only is the
immediately adjacent bookmark brackets lost, the FORM FIELD itself likewise is destroyed, together replaced instead by the corrected word. -- spassky "jarimura" wrote: I tried to insert the code as you recommended. However, I am still running into a problem, whenever the form field is filled in using only ONE word, e.g., Detroit in the form field bookmarked City, for instance. Lets say I misspelled Detroit dtrr. When I run the macro, it will recognize the error, and the view box Spelling: English (U.S.) will appear, apparently not only highlighting the misspelled word, but also the immediately adjacent BOOKMARK BRACKETS. When I double click on the error in the view box to select the ENTIRE word, not only is the misspelled word itself highlighted but also the immediately adjacent BOOKMARK BRACKETS as well. When I proceed to input the correction, the corrected word (in this instance, Detroit is inserted into the document, but at the same time the bookmark itself is destroyed. So now the referenced field will no longer have bookmark referenced to, and I get a Run-time 424 error. I hope this clarifies the difficulty I am experiencing. Thanks. -- spassky "Doug Robbins - Word MVP" wrote: In my testing, using the macro that is provided on the Word MVP website does not destroy the bookmarks that are assigned either automatically or manually to the formfields via the formfield properties dialog or by using InsertBookmark. If however the spelling of a work in a referenced formfield is corrected, the cross reference is updated. If you insert the following lines of code oDoc.PrintPreview oDoc.ClosePrintPreview before the line oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True the cross references will be updated. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "jarimura" wrote in message ... I wish I could share with you one custom document I had created with numerous form fields, referenced (REF) fields, and bookmarks. So, I will attempt to describe how my form works, short of sending one as an attachment. The document is a actually a template for a physical examination form utilized by the Department of Transportation, containing fields for the individual's name (bookmarked "PatientName"), address (bookmarked "Address"), State (bookmarked "State"), examiner's name (bookmarked "Examiner"), etc. The exam findings, as well as the individual's personal information, are entered into the protected form fields manually. There is a certificate at the end of the exam, with the individual's name, address, state, zip code, examiner's name, etc. As these are redundant information, my form automatically will complete it with the information already entered in the earlier form fields. As the relevant form fields have already been bookmarked, the referenced fields on the certificate are automatically updated accordingly. I have tested the form such that it would do this, even when completely protected, so I can reuse the form over and over. Let's say on the form just described, I misspelled "Detroit" in the protected form field. I would then like to run a macro to check for such misspelling. I came close, using the macro provided, but then I ran into my current problem. By the way, I am running Word 2000, running on Windows XP Professional or Windows 2000 Professional. Thanks, once again. -- spassky "Charles Kenyon" wrote: What is wrong with using the original macro? What is your adaptation? What is it supposed to do for you? (In case you haven't guessed, I didn't trace through your code. If you want someone to do that, I would suggest posting in one of the vba newsgroups rather than this one dealing with document management.) I can tell you that the one on the website has worked fine for me with numerous forms, both as a macro in the form template and as a macro in a global template. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... Doing that only created 2 ADDITIONAL problems, namely (1) the bookmark is destroyed after protecting the document, and (2) the reference field referring back to the bookmark no longer works. PERHAPS, I probably need someone to revise the macro (initially posted). -- spassky "Charles Kenyon" wrote: If your bookmarks are set in the formfield properties do you still have the problem? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I have a document with several form fields that in turn are assigned bookmarks (e.g., PatientName), to allow automatic filling of the referenced fields. This works when the form is protected. However, when I attempted to use the following spell checking macro to check the contents of the form fields themselves (adapted from the macro written by contributed by Dave Rado, Bill Coan, and Astrid Zeelenberg on the MVP website, http://word.mvps.org/faqs/macrosvba/...ProtectDoc.htm) with the form protected, I end up LOSING THE BOOKMARK: Sub RunSpellcheck() Dim Cancelled As Boolean, MyRange As Range, _ CorrectedError As String, oDoc As Document Dim oSection As Section, OriginalRange As Range If Documents.Count = 0 Then Exit Sub End If Set oDoc = ActiveDocument Select Case oDoc.ProtectionType Case wdNoProtection, wdAllowOnlyRevisions If Options.CheckGrammarWithSpelling Then oDoc.CheckGrammar Else oDoc.CheckSpelling End If Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Exit Sub Case wdAllowOnlyComments Exit Sub End Select Set OriginalRange = Selection.Range System.Cursor = wdCursorWait oDoc.Unprotect oDoc.SpellingChecked = False StatusBar = "Spellchecking document..." For Each oSection In oDoc.Sections If oSection.ProtectedForForms Then Call CheckProtectedSection(oSection) If Cancelled Then Exit For End If Else If oSection.Range.SpellingErrors.Count 0 Then Application.ScreenUpdating = True oSection.Range.CheckSpelling If oSection.Range.SpellingErrors.Count 0 Then Exit For End If End If End If Next oSection oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True OriginalRange.Select Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.Range.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Cancelled = False CorrectedError = vbNullString Set MyRange = Nothing End Sub Private Sub CheckProtectedSection(oSection As Section) 'Checks ONLY the TEXT formfields but NOT listboxes or checkboxes. Dim FmFld As FormField, FmFldCount As Long, Pos As Long Application.ScreenUpdating = False For Each FmFld In oSection.Range.FormFields If FmFld.Type = wdFieldFormTextInput Then If FmFld.TextInput.Type = wdRegularText And FmFld.Enabled Then If Not Left$(Application.Version, 1) = "8" Then Call TurnNoProofingOff(FmFld) End If FmFld.Range.SpellingChecked = False FmFld.Range.LanguageID = wdEnglishUS If FmFld.Range.SpellingErrors.Count 0 Then If Left$(Application.Version, 1) = "8" _ And FmFld.Range.Paragraphs.Count 1 _ And FmFld.Range.Tables.Count 0 Then Call Word97TableBugWorkaround(FmFld) If Cancelled Then Exit Sub Else Set MyRange = FmFld.Range FmFldCount = oSection.Range.FormFields.Count Application.ScreenUpdating = True FmFld.Range.CheckSpelling If IsObjectValid(FmFld) Then If FmFld.Range.SpellingErrors.Count 0 Then Cancelled = True Exit Sub End If Else CorrectedError = MyRange.Text If Len(CorrectedError) = 0 Then CorrectedError = MyRange.Words(1).Text End If Pos = InStr(CorrectedError, vbTab) Do While Pos 0 CorrectedError = Mid$(CorrectedError, Pos + 1) Pos = InStr(CorrectedError, vbTab) Loop Do While Not FmFldCount = _ oSection.Range.FormFields.Count oDoc.Undo Loop If Selection.FormFields.Count = 0 Then Selection.MoveRight unit:=wdCharacter Selection.MoveLeft unit:=wdCharacter, Extend:=True End If If Not IsObjectValid(FmFld) Then Set FmFld = Selection.FormFields(1) End If FmFld.Result = CorrectedError End If End If Application.ScreenUpdating = False End If End If End If Next FmFld End Sub Private Sub TurnNoProofingOff(FmFld As FormField) |
#10
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
The macro does not replace form fields, it might replace other fields,
although I don' think so. Anytime you write adjacent to a bookmark you are likely to delete the bookmark. That is only one of the reasons to use the built-in bookmarks that come with formfields. Formfields are not deleted by this macro. Why are you inserting separate bookmarks? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I tried to insert the code as you recommended. However, I am still running into a problem, whenever the form field is filled in using only ONE word, e.g., "Detroit" in the form field bookmarked City, for instance. Let's say I misspelled "Detroit" "dtrr". When I run the macro, it will recognize the error, and the view box Spelling: English (U.S.) will appear, apparently not only highlighting the misspelled word, but also the immediately adjacent BOOKMARK BRACKETS. When I double click on the error in the view box to select the ENTIRE word, not only is the misspelled word itself highlighted but also the immediately adjacent BOOKMARK BRACKETS as well. When I proceed to input the correction, the corrected word (in this instance, "Detroit" is inserted into the document, but at the same time the bookmark itself is destroyed. So now the referenced field will no longer have bookmark referenced to, and I get a Run-time 424 error. I hope this clarifies the difficulty I am experiencing. Thanks. -- spassky "Doug Robbins - Word MVP" wrote: In my testing, using the macro that is provided on the Word MVP website does not destroy the bookmarks that are assigned either automatically or manually to the formfields via the formfield properties dialog or by using InsertBookmark. If however the spelling of a work in a referenced formfield is corrected, the cross reference is updated. If you insert the following lines of code oDoc.PrintPreview oDoc.ClosePrintPreview before the line oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True the cross references will be updated. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "jarimura" wrote in message ... I wish I could share with you one custom document I had created with numerous form fields, referenced (REF) fields, and bookmarks. So, I will attempt to describe how my form works, short of sending one as an attachment. The document is a actually a template for a physical examination form utilized by the Department of Transportation, containing fields for the individual's name (bookmarked "PatientName"), address (bookmarked "Address"), State (bookmarked "State"), examiner's name (bookmarked "Examiner"), etc. The exam findings, as well as the individual's personal information, are entered into the protected form fields manually. There is a certificate at the end of the exam, with the individual's name, address, state, zip code, examiner's name, etc. As these are redundant information, my form automatically will complete it with the information already entered in the earlier form fields. As the relevant form fields have already been bookmarked, the referenced fields on the certificate are automatically updated accordingly. I have tested the form such that it would do this, even when completely protected, so I can reuse the form over and over. Let's say on the form just described, I misspelled "Detroit" in the protected form field. I would then like to run a macro to check for such misspelling. I came close, using the macro provided, but then I ran into my current problem. By the way, I am running Word 2000, running on Windows XP Professional or Windows 2000 Professional. Thanks, once again. -- spassky "Charles Kenyon" wrote: What is wrong with using the original macro? What is your adaptation? What is it supposed to do for you? (In case you haven't guessed, I didn't trace through your code. If you want someone to do that, I would suggest posting in one of the vba newsgroups rather than this one dealing with document management.) I can tell you that the one on the website has worked fine for me with numerous forms, both as a macro in the form template and as a macro in a global template. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... Doing that only created 2 ADDITIONAL problems, namely (1) the bookmark is destroyed after protecting the document, and (2) the reference field referring back to the bookmark no longer works. PERHAPS, I probably need someone to revise the macro (initially posted). -- spassky "Charles Kenyon" wrote: If your bookmarks are set in the formfield properties do you still have the problem? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I have a document with several form fields that in turn are assigned bookmarks (e.g., PatientName), to allow automatic filling of the referenced fields. This works when the form is protected. However, when I attempted to use the following spell checking macro to check the contents of the form fields themselves (adapted from the macro written by contributed by Dave Rado, Bill Coan, and Astrid Zeelenberg on the MVP website, http://word.mvps.org/faqs/macrosvba/...ProtectDoc.htm) with the form protected, I end up LOSING THE BOOKMARK: Sub RunSpellcheck() Dim Cancelled As Boolean, MyRange As Range, _ CorrectedError As String, oDoc As Document Dim oSection As Section, OriginalRange As Range If Documents.Count = 0 Then Exit Sub End If Set oDoc = ActiveDocument Select Case oDoc.ProtectionType Case wdNoProtection, wdAllowOnlyRevisions If Options.CheckGrammarWithSpelling Then oDoc.CheckGrammar Else oDoc.CheckSpelling End If Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Exit Sub Case wdAllowOnlyComments Exit Sub End Select Set OriginalRange = Selection.Range System.Cursor = wdCursorWait oDoc.Unprotect oDoc.SpellingChecked = False StatusBar = "Spellchecking document..." For Each oSection In oDoc.Sections If oSection.ProtectedForForms Then Call CheckProtectedSection(oSection) If Cancelled Then Exit For End If Else If oSection.Range.SpellingErrors.Count 0 Then Application.ScreenUpdating = True oSection.Range.CheckSpelling If oSection.Range.SpellingErrors.Count 0 Then Exit For End If End If End If Next oSection oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True OriginalRange.Select Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.Range.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Cancelled = False CorrectedError = vbNullString Set MyRange = Nothing End Sub Private Sub CheckProtectedSection(oSection As Section) 'Checks ONLY the TEXT formfields but NOT listboxes or checkboxes. Dim FmFld As FormField, FmFldCount As Long, Pos As Long Application.ScreenUpdating = False For Each FmFld In oSection.Range.FormFields If FmFld.Type = wdFieldFormTextInput Then If FmFld.TextInput.Type = wdRegularText And FmFld.Enabled Then If Not Left$(Application.Version, 1) = "8" Then Call TurnNoProofingOff(FmFld) End If FmFld.Range.SpellingChecked = False FmFld.Range.LanguageID = wdEnglishUS If FmFld.Range.SpellingErrors.Count 0 Then If Left$(Application.Version, 1) = "8" _ And FmFld.Range.Paragraphs.Count 1 _ And FmFld.Range.Tables.Count 0 Then Call Word97TableBugWorkaround(FmFld) If Cancelled Then Exit Sub Else Set MyRange = FmFld.Range FmFldCount = oSection.Range.FormFields.Count Application.ScreenUpdating = True FmFld.Range.CheckSpelling If IsObjectValid(FmFld) Then If FmFld.Range.SpellingErrors.Count 0 Then Cancelled = True Exit Sub End If Else CorrectedError = MyRange.Text If Len(CorrectedError) = 0 Then CorrectedError = MyRange.Words(1).Text End If Pos = InStr(CorrectedError, vbTab) Do While Pos 0 CorrectedError = Mid$(CorrectedError, Pos + 1) Pos = InStr(CorrectedError, vbTab) Loop Do While Not FmFldCount = _ oSection.Range.FormFields.Count oDoc.Undo Loop If Selection.FormFields.Count = 0 Then Selection.MoveRight unit:=wdCharacter Selection.MoveLeft unit:=wdCharacter, Extend:=True End If If Not IsObjectValid(FmFld) Then Set FmFld = Selection.FormFields(1) End If FmFld.Result = CorrectedError End If End If Application.ScreenUpdating = False End If End If End If Next FmFld End Sub Private Sub TurnNoProofingOff(FmFld As FormField) 'This subroutine is called only in Word 2000 and above FmFld.Range.NoProofing = False End Sub Private Sub Word97TableBugWorkaround(FmFld As FormField) Set MyRange = FmFld.Range FmFld.Range.Fields(1).Unlink Application.ScreenUpdating = True MyRange.CheckSpelling If MyRange.SpellingErrors.Count 0 Then Cancelled = True End If CorrectedError = MyRange.Text Do While Not IsObjectValid(FmFld) oDoc.Undo Loop FmFld.Range.Fields(1).Result.Text = CorrectedError Application.ScreenUpdating = False End Sub That in turn causes the referenced fields to NOT work. Would anyone know the solution to this particular problem? |
#11
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
If you are typing the correction into the Spelling dialog, you will need to
turn on the display of bookmarks via ToolsOptionsView so that the bookmarks are displayed in the Spelling dialog, and you will need to be careful that YOU do not delete the bookmarks when you enter the corrected spelling. It is NOT the macro that is deleting the bookmarks, it is the OPERATOR. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "jarimura" wrote in message ... I would like to ADD the following to my most recent reply. Not only is the immediately adjacent bookmark brackets lost, the FORM FIELD itself likewise is destroyed, together replaced instead by the corrected word. -- spassky "jarimura" wrote: I tried to insert the code as you recommended. However, I am still running into a problem, whenever the form field is filled in using only ONE word, e.g., "Detroit" in the form field bookmarked City, for instance. Let's say I misspelled "Detroit" "dtrr". When I run the macro, it will recognize the error, and the view box Spelling: English (U.S.) will appear, apparently not only highlighting the misspelled word, but also the immediately adjacent BOOKMARK BRACKETS. When I double click on the error in the view box to select the ENTIRE word, not only is the misspelled word itself highlighted but also the immediately adjacent BOOKMARK BRACKETS as well. When I proceed to input the correction, the corrected word (in this instance, "Detroit" is inserted into the document, but at the same time the bookmark itself is destroyed. So now the referenced field will no longer have bookmark referenced to, and I get a Run-time 424 error. I hope this clarifies the difficulty I am experiencing. Thanks. -- spassky "Doug Robbins - Word MVP" wrote: In my testing, using the macro that is provided on the Word MVP website does not destroy the bookmarks that are assigned either automatically or manually to the formfields via the formfield properties dialog or by using InsertBookmark. If however the spelling of a work in a referenced formfield is corrected, the cross reference is updated. If you insert the following lines of code oDoc.PrintPreview oDoc.ClosePrintPreview before the line oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True the cross references will be updated. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "jarimura" wrote in message ... I wish I could share with you one custom document I had created with numerous form fields, referenced (REF) fields, and bookmarks. So, I will attempt to describe how my form works, short of sending one as an attachment. The document is a actually a template for a physical examination form utilized by the Department of Transportation, containing fields for the individual's name (bookmarked "PatientName"), address (bookmarked "Address"), State (bookmarked "State"), examiner's name (bookmarked "Examiner"), etc. The exam findings, as well as the individual's personal information, are entered into the protected form fields manually. There is a certificate at the end of the exam, with the individual's name, address, state, zip code, examiner's name, etc. As these are redundant information, my form automatically will complete it with the information already entered in the earlier form fields. As the relevant form fields have already been bookmarked, the referenced fields on the certificate are automatically updated accordingly. I have tested the form such that it would do this, even when completely protected, so I can reuse the form over and over. Let's say on the form just described, I misspelled "Detroit" in the protected form field. I would then like to run a macro to check for such misspelling. I came close, using the macro provided, but then I ran into my current problem. By the way, I am running Word 2000, running on Windows XP Professional or Windows 2000 Professional. Thanks, once again. -- spassky "Charles Kenyon" wrote: What is wrong with using the original macro? What is your adaptation? What is it supposed to do for you? (In case you haven't guessed, I didn't trace through your code. If you want someone to do that, I would suggest posting in one of the vba newsgroups rather than this one dealing with document management.) I can tell you that the one on the website has worked fine for me with numerous forms, both as a macro in the form template and as a macro in a global template. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... Doing that only created 2 ADDITIONAL problems, namely (1) the bookmark is destroyed after protecting the document, and (2) the reference field referring back to the bookmark no longer works. PERHAPS, I probably need someone to revise the macro (initially posted). -- spassky "Charles Kenyon" wrote: If your bookmarks are set in the formfield properties do you still have the problem? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I have a document with several form fields that in turn are assigned bookmarks (e.g., PatientName), to allow automatic filling of the referenced fields. This works when the form is protected. However, when I attempted to use the following spell checking macro to check the contents of the form fields themselves (adapted from the macro written by contributed by Dave Rado, Bill Coan, and Astrid Zeelenberg on the MVP website, http://word.mvps.org/faqs/macrosvba/...ProtectDoc.htm) with the form protected, I end up LOSING THE BOOKMARK: Sub RunSpellcheck() Dim Cancelled As Boolean, MyRange As Range, _ CorrectedError As String, oDoc As Document Dim oSection As Section, OriginalRange As Range If Documents.Count = 0 Then Exit Sub End If Set oDoc = ActiveDocument Select Case oDoc.ProtectionType Case wdNoProtection, wdAllowOnlyRevisions If Options.CheckGrammarWithSpelling Then oDoc.CheckGrammar Else oDoc.CheckSpelling End If Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Exit Sub Case wdAllowOnlyComments Exit Sub End Select Set OriginalRange = Selection.Range System.Cursor = wdCursorWait oDoc.Unprotect oDoc.SpellingChecked = False StatusBar = "Spellchecking document..." For Each oSection In oDoc.Sections If oSection.ProtectedForForms Then Call CheckProtectedSection(oSection) If Cancelled Then Exit For End If Else If oSection.Range.SpellingErrors.Count 0 Then Application.ScreenUpdating = True oSection.Range.CheckSpelling If oSection.Range.SpellingErrors.Count 0 Then Exit For End If End If End If Next oSection oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True OriginalRange.Select Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.Range.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Cancelled = False CorrectedError = vbNullString Set MyRange = Nothing End Sub Private Sub CheckProtectedSection(oSection As Section) 'Checks ONLY the TEXT formfields but NOT listboxes or checkboxes. Dim FmFld As FormField, FmFldCount As Long, Pos As Long Application.ScreenUpdating = False For Each FmFld In oSection.Range.FormFields If FmFld.Type = wdFieldFormTextInput Then If FmFld.TextInput.Type = wdRegularText And FmFld.Enabled Then If Not Left$(Application.Version, 1) = "8" Then Call TurnNoProofingOff(FmFld) End If FmFld.Range.SpellingChecked = False FmFld.Range.LanguageID = wdEnglishUS If FmFld.Range.SpellingErrors.Count 0 Then If Left$(Application.Version, 1) = "8" _ And FmFld.Range.Paragraphs.Count 1 _ And FmFld.Range.Tables.Count 0 Then Call Word97TableBugWorkaround(FmFld) If Cancelled Then Exit Sub Else Set MyRange = FmFld.Range FmFldCount = oSection.Range.FormFields.Count Application.ScreenUpdating = True FmFld.Range.CheckSpelling If IsObjectValid(FmFld) Then If FmFld.Range.SpellingErrors.Count 0 Then Cancelled = True Exit Sub End If Else CorrectedError = MyRange.Text If Len(CorrectedError) = 0 Then CorrectedError = MyRange.Words(1).Text End If Pos = InStr(CorrectedError, vbTab) Do While Pos 0 CorrectedError = Mid$(CorrectedError, Pos + 1) Pos = InStr(CorrectedError, vbTab) Loop Do While Not FmFldCount = _ oSection.Range.FormFields.Count oDoc.Undo Loop If Selection.FormFields.Count = 0 Then Selection.MoveRight unit:=wdCharacter Selection.MoveLeft unit:=wdCharacter, Extend:=True End If If Not IsObjectValid(FmFld) Then Set FmFld = Selection.FormFields(1) End If FmFld.Result = CorrectedError End If End If Application.ScreenUpdating = False End If End If End If Next FmFld End Sub Private Sub TurnNoProofingOff(FmFld As FormField) |
#12
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
When I create a form field, a generic bookmark (e.g., Text1) is
automatically assigned the form field. What I have been doing in customizing the form is to go into the Properties of the form field, and simply change the name of the default bookmark e.g., Text1 to a more readily identifiable name, say PatientName, that I can reference to later in the same document. So, I am NOT inserting another bookmark, but simply renaming it, keeping all the other parameters unchanged. The macro DOES appear to work, IF the form field contains MORE THAN ONE WORD; in that situation, I have been able to select the misspelled word amongst a group of words (contained in the same field) in question to make the correction. So, YES in THAT SITUATION, the macro does not replace the field or the bookmark in question. HOWEVER, in the case whereby the form field contains only ONE word say Detriot and you proceed to highlight it by double clicking on the word, inadvertently, not only the word itself, but also the FORM FIELD and the immediately adjacent BOOKMARK BRACKETS are also selected. When that happens and I proceed to make the correction, this macro results in LOSS of BOTH the form field and the bookmark. My document has a number of form fields, whereby the asked-for information consists only of ONE word. Perhaps, there is a way to allow one to double click on the solitary word in the filled-out form field to select it during the execution of the spellchecker macro on a protected document that ONLY the word itself, NOT the form field and the adjacent bookmark brackets, are selected. Thanks, once again. -- spassky "Charles Kenyon" wrote: The macro does not replace form fields, it might replace other fields, although I don' think so. Anytime you write adjacent to a bookmark you are likely to delete the bookmark. That is only one of the reasons to use the built-in bookmarks that come with formfields. Formfields are not deleted by this macro. Why are you inserting separate bookmarks? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I tried to insert the code as you recommended. However, I am still running into a problem, whenever the form field is filled in using only ONE word, e.g., "Detroit" in the form field bookmarked City, for instance. Let's say I misspelled "Detroit" "dtrr". When I run the macro, it will recognize the error, and the view box Spelling: English (U.S.) will appear, apparently not only highlighting the misspelled word, but also the immediately adjacent BOOKMARK BRACKETS. When I double click on the error in the view box to select the ENTIRE word, not only is the misspelled word itself highlighted but also the immediately adjacent BOOKMARK BRACKETS as well. When I proceed to input the correction, the corrected word (in this instance, "Detroit" is inserted into the document, but at the same time the bookmark itself is destroyed. So now the referenced field will no longer have bookmark referenced to, and I get a Run-time 424 error. I hope this clarifies the difficulty I am experiencing. Thanks. -- spassky "Doug Robbins - Word MVP" wrote: In my testing, using the macro that is provided on the Word MVP website does not destroy the bookmarks that are assigned either automatically or manually to the formfields via the formfield properties dialog or by using InsertBookmark. If however the spelling of a work in a referenced formfield is corrected, the cross reference is updated. If you insert the following lines of code oDoc.PrintPreview oDoc.ClosePrintPreview before the line oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True the cross references will be updated. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "jarimura" wrote in message ... I wish I could share with you one custom document I had created with numerous form fields, referenced (REF) fields, and bookmarks. So, I will attempt to describe how my form works, short of sending one as an attachment. The document is a actually a template for a physical examination form utilized by the Department of Transportation, containing fields for the individual's name (bookmarked "PatientName"), address (bookmarked "Address"), State (bookmarked "State"), examiner's name (bookmarked "Examiner"), etc. The exam findings, as well as the individual's personal information, are entered into the protected form fields manually. There is a certificate at the end of the exam, with the individual's name, address, state, zip code, examiner's name, etc. As these are redundant information, my form automatically will complete it with the information already entered in the earlier form fields. As the relevant form fields have already been bookmarked, the referenced fields on the certificate are automatically updated accordingly. I have tested the form such that it would do this, even when completely protected, so I can reuse the form over and over. Let's say on the form just described, I misspelled "Detroit" in the protected form field. I would then like to run a macro to check for such misspelling. I came close, using the macro provided, but then I ran into my current problem. By the way, I am running Word 2000, running on Windows XP Professional or Windows 2000 Professional. Thanks, once again. -- spassky "Charles Kenyon" wrote: What is wrong with using the original macro? What is your adaptation? What is it supposed to do for you? (In case you haven't guessed, I didn't trace through your code. If you want someone to do that, I would suggest posting in one of the vba newsgroups rather than this one dealing with document management.) I can tell you that the one on the website has worked fine for me with numerous forms, both as a macro in the form template and as a macro in a global template. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... Doing that only created 2 ADDITIONAL problems, namely (1) the bookmark is destroyed after protecting the document, and (2) the reference field referring back to the bookmark no longer works. PERHAPS, I probably need someone to revise the macro (initially posted). -- spassky "Charles Kenyon" wrote: If your bookmarks are set in the formfield properties do you still have the problem? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I have a document with several form fields that in turn are assigned bookmarks (e.g., PatientName), to allow automatic filling of the referenced fields. This works when the form is protected. However, when I attempted to use the following spell checking macro to check the contents of the form fields themselves (adapted from the macro written by contributed by Dave Rado, Bill Coan, and Astrid Zeelenberg on the MVP website, http://word.mvps.org/faqs/macrosvba/...ProtectDoc.htm) with the form protected, I end up LOSING THE BOOKMARK: Sub RunSpellcheck() Dim Cancelled As Boolean, MyRange As Range, _ CorrectedError As String, oDoc As Document Dim oSection As Section, OriginalRange As Range If Documents.Count = 0 Then Exit Sub End If Set oDoc = ActiveDocument Select Case oDoc.ProtectionType Case wdNoProtection, wdAllowOnlyRevisions If Options.CheckGrammarWithSpelling Then oDoc.CheckGrammar Else oDoc.CheckSpelling End If Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Exit Sub Case wdAllowOnlyComments Exit Sub End Select Set OriginalRange = Selection.Range System.Cursor = wdCursorWait oDoc.Unprotect oDoc.SpellingChecked = False StatusBar = "Spellchecking document..." For Each oSection In oDoc.Sections If oSection.ProtectedForForms Then Call CheckProtectedSection(oSection) If Cancelled Then Exit For End If Else If oSection.Range.SpellingErrors.Count 0 Then Application.ScreenUpdating = True oSection.Range.CheckSpelling If oSection.Range.SpellingErrors.Count 0 Then Exit For End If End If End If Next oSection oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True OriginalRange.Select Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.Range.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Cancelled = False CorrectedError = vbNullString Set MyRange = Nothing End Sub Private Sub CheckProtectedSection(oSection As Section) 'Checks ONLY the TEXT formfields but NOT listboxes or checkboxes. Dim FmFld As FormField, FmFldCount As Long, Pos As Long Application.ScreenUpdating = False For Each FmFld In oSection.Range.FormFields If FmFld.Type = wdFieldFormTextInput Then If FmFld.TextInput.Type = wdRegularText And FmFld.Enabled Then If Not Left$(Application.Version, 1) = "8" Then Call TurnNoProofingOff(FmFld) End If FmFld.Range.SpellingChecked = False FmFld.Range.LanguageID = wdEnglishUS If FmFld.Range.SpellingErrors.Count 0 Then If Left$(Application.Version, 1) = "8" _ And FmFld.Range.Paragraphs.Count 1 _ |
#13
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Ah, we are finally getting to the heart of the problem! It would be nice to
be able to simply DOUBLE CLICK on the misspelled word in the Spelling dialog box to select ONLY the word, instead of painstakingly highlighting the word by dragging the cursor from the first letter of the word to the last letter and being careful to NOT highlight the bookmarks. Wouldnt it be so much easier to simply double click on the word and have ONLY the word itself and not the bookmarks be selected? So, IS there a way to achieve this? Thanks, once again. spassky "Doug Robbins - Word MVP" wrote: If you are typing the correction into the Spelling dialog, you will need to turn on the display of bookmarks via ToolsOptionsView so that the bookmarks are displayed in the Spelling dialog, and you will need to be careful that YOU do not delete the bookmarks when you enter the corrected spelling. It is NOT the macro that is deleting the bookmarks, it is the OPERATOR. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "jarimura" wrote in message ... I would like to ADD the following to my most recent reply. Not only is the immediately adjacent bookmark brackets lost, the FORM FIELD itself likewise is destroyed, together replaced instead by the corrected word. -- spassky "jarimura" wrote: I tried to insert the code as you recommended. However, I am still running into a problem, whenever the form field is filled in using only ONE word, e.g., "Detroit" in the form field bookmarked City, for instance. Let's say I misspelled "Detroit" "dtrr". When I run the macro, it will recognize the error, and the view box Spelling: English (U.S.) will appear, apparently not only highlighting the misspelled word, but also the immediately adjacent BOOKMARK BRACKETS. When I double click on the error in the view box to select the ENTIRE word, not only is the misspelled word itself highlighted but also the immediately adjacent BOOKMARK BRACKETS as well. When I proceed to input the correction, the corrected word (in this instance, "Detroit" is inserted into the document, but at the same time the bookmark itself is destroyed. So now the referenced field will no longer have bookmark referenced to, and I get a Run-time 424 error. I hope this clarifies the difficulty I am experiencing. Thanks. -- spassky "Doug Robbins - Word MVP" wrote: In my testing, using the macro that is provided on the Word MVP website does not destroy the bookmarks that are assigned either automatically or manually to the formfields via the formfield properties dialog or by using InsertBookmark. If however the spelling of a work in a referenced formfield is corrected, the cross reference is updated. If you insert the following lines of code oDoc.PrintPreview oDoc.ClosePrintPreview before the line oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True the cross references will be updated. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "jarimura" wrote in message ... I wish I could share with you one custom document I had created with numerous form fields, referenced (REF) fields, and bookmarks. So, I will attempt to describe how my form works, short of sending one as an attachment. The document is a actually a template for a physical examination form utilized by the Department of Transportation, containing fields for the individual's name (bookmarked "PatientName"), address (bookmarked "Address"), State (bookmarked "State"), examiner's name (bookmarked "Examiner"), etc. The exam findings, as well as the individual's personal information, are entered into the protected form fields manually. There is a certificate at the end of the exam, with the individual's name, address, state, zip code, examiner's name, etc. As these are redundant information, my form automatically will complete it with the information already entered in the earlier form fields. As the relevant form fields have already been bookmarked, the referenced fields on the certificate are automatically updated accordingly. I have tested the form such that it would do this, even when completely protected, so I can reuse the form over and over. Let's say on the form just described, I misspelled "Detroit" in the protected form field. I would then like to run a macro to check for such misspelling. I came close, using the macro provided, but then I ran into my current problem. By the way, I am running Word 2000, running on Windows XP Professional or Windows 2000 Professional. Thanks, once again. -- spassky "Charles Kenyon" wrote: What is wrong with using the original macro? What is your adaptation? What is it supposed to do for you? (In case you haven't guessed, I didn't trace through your code. If you want someone to do that, I would suggest posting in one of the vba newsgroups rather than this one dealing with document management.) I can tell you that the one on the website has worked fine for me with numerous forms, both as a macro in the form template and as a macro in a global template. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... Doing that only created 2 ADDITIONAL problems, namely (1) the bookmark is destroyed after protecting the document, and (2) the reference field referring back to the bookmark no longer works. PERHAPS, I probably need someone to revise the macro (initially posted). -- spassky "Charles Kenyon" wrote: If your bookmarks are set in the formfield properties do you still have the problem? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I have a document with several form fields that in turn are assigned bookmarks (e.g., PatientName), to allow automatic filling of the referenced fields. This works when the form is protected. However, when I attempted to use the following spell checking macro to check the contents of the form fields themselves (adapted from the macro written by contributed by Dave Rado, Bill Coan, and Astrid Zeelenberg on the MVP website, http://word.mvps.org/faqs/macrosvba/...ProtectDoc.htm) with the form protected, I end up LOSING THE BOOKMARK: Sub RunSpellcheck() Dim Cancelled As Boolean, MyRange As Range, _ CorrectedError As String, oDoc As Document Dim oSection As Section, OriginalRange As Range If Documents.Count = 0 Then Exit Sub End If Set oDoc = ActiveDocument Select Case oDoc.ProtectionType Case wdNoProtection, wdAllowOnlyRevisions If Options.CheckGrammarWithSpelling Then oDoc.CheckGrammar Else oDoc.CheckSpelling End If Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Exit Sub Case wdAllowOnlyComments Exit Sub End Select Set OriginalRange = Selection.Range System.Cursor = wdCursorWait oDoc.Unprotect oDoc.SpellingChecked = False StatusBar = "Spellchecking document..." For Each oSection In oDoc.Sections If oSection.ProtectedForForms Then Call CheckProtectedSection(oSection) If Cancelled Then Exit For End If Else If oSection.Range.SpellingErrors.Count 0 Then Application.ScreenUpdating = True oSection.Range.CheckSpelling If oSection.Range.SpellingErrors.Count 0 Then Exit For End If End If End If Next oSection oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True OriginalRange.Select Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.Range.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If |
#14
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
That is the nature of bookmarks. They are very fragile. You are right, it
would be nice to be able to double-click on a word and have it not zap the bookmark. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... Ah, we are finally getting to the heart of the problem! It would be nice to be able to simply DOUBLE CLICK on the misspelled word in the Spelling dialog box to select ONLY the word, instead of "painstakingly" highlighting the word by dragging the cursor from the first letter of the word to the last letter and being careful to NOT highlight the bookmarks. Wouldn't it be so much easier to simply double click on the word and have ONLY the word itself and not the bookmarks be selected? So, IS there a way to achieve this? Thanks, once again. spassky "Doug Robbins - Word MVP" wrote: If you are typing the correction into the Spelling dialog, you will need to turn on the display of bookmarks via ToolsOptionsView so that the bookmarks are displayed in the Spelling dialog, and you will need to be careful that YOU do not delete the bookmarks when you enter the corrected spelling. It is NOT the macro that is deleting the bookmarks, it is the OPERATOR. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "jarimura" wrote in message ... I would like to ADD the following to my most recent reply. Not only is the immediately adjacent bookmark brackets lost, the FORM FIELD itself likewise is destroyed, together replaced instead by the corrected word. -- spassky "jarimura" wrote: I tried to insert the code as you recommended. However, I am still running into a problem, whenever the form field is filled in using only ONE word, e.g., "Detroit" in the form field bookmarked City, for instance. Let's say I misspelled "Detroit" "dtrr". When I run the macro, it will recognize the error, and the view box Spelling: English (U.S.) will appear, apparently not only highlighting the misspelled word, but also the immediately adjacent BOOKMARK BRACKETS. When I double click on the error in the view box to select the ENTIRE word, not only is the misspelled word itself highlighted but also the immediately adjacent BOOKMARK BRACKETS as well. When I proceed to input the correction, the corrected word (in this instance, "Detroit" is inserted into the document, but at the same time the bookmark itself is destroyed. So now the referenced field will no longer have bookmark referenced to, and I get a Run-time 424 error. I hope this clarifies the difficulty I am experiencing. Thanks. -- spassky "Doug Robbins - Word MVP" wrote: In my testing, using the macro that is provided on the Word MVP website does not destroy the bookmarks that are assigned either automatically or manually to the formfields via the formfield properties dialog or by using InsertBookmark. If however the spelling of a work in a referenced formfield is corrected, the cross reference is updated. If you insert the following lines of code oDoc.PrintPreview oDoc.ClosePrintPreview before the line oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True the cross references will be updated. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "jarimura" wrote in message ... I wish I could share with you one custom document I had created with numerous form fields, referenced (REF) fields, and bookmarks. So, I will attempt to describe how my form works, short of sending one as an attachment. The document is a actually a template for a physical examination form utilized by the Department of Transportation, containing fields for the individual's name (bookmarked "PatientName"), address (bookmarked "Address"), State (bookmarked "State"), examiner's name (bookmarked "Examiner"), etc. The exam findings, as well as the individual's personal information, are entered into the protected form fields manually. There is a certificate at the end of the exam, with the individual's name, address, state, zip code, examiner's name, etc. As these are redundant information, my form automatically will complete it with the information already entered in the earlier form fields. As the relevant form fields have already been bookmarked, the referenced fields on the certificate are automatically updated accordingly. I have tested the form such that it would do this, even when completely protected, so I can reuse the form over and over. Let's say on the form just described, I misspelled "Detroit" in the protected form field. I would then like to run a macro to check for such misspelling. I came close, using the macro provided, but then I ran into my current problem. By the way, I am running Word 2000, running on Windows XP Professional or Windows 2000 Professional. Thanks, once again. -- spassky "Charles Kenyon" wrote: What is wrong with using the original macro? What is your adaptation? What is it supposed to do for you? (In case you haven't guessed, I didn't trace through your code. If you want someone to do that, I would suggest posting in one of the vba newsgroups rather than this one dealing with document management.) I can tell you that the one on the website has worked fine for me with numerous forms, both as a macro in the form template and as a macro in a global template. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... Doing that only created 2 ADDITIONAL problems, namely (1) the bookmark is destroyed after protecting the document, and (2) the reference field referring back to the bookmark no longer works. PERHAPS, I probably need someone to revise the macro (initially posted). -- spassky "Charles Kenyon" wrote: If your bookmarks are set in the formfield properties do you still have the problem? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I have a document with several form fields that in turn are assigned bookmarks (e.g., PatientName), to allow automatic filling of the referenced fields. This works when the form is protected. However, when I attempted to use the following spell checking macro to check the contents of the form fields themselves (adapted from the macro written by contributed by Dave Rado, Bill Coan, and Astrid Zeelenberg on the MVP website, http://word.mvps.org/faqs/macrosvba/...ProtectDoc.htm) with the form protected, I end up LOSING THE BOOKMARK: Sub RunSpellcheck() Dim Cancelled As Boolean, MyRange As Range, _ CorrectedError As String, oDoc As Document Dim oSection As Section, OriginalRange As Range If Documents.Count = 0 Then Exit Sub End If Set oDoc = ActiveDocument Select Case oDoc.ProtectionType Case wdNoProtection, wdAllowOnlyRevisions If Options.CheckGrammarWithSpelling Then oDoc.CheckGrammar Else oDoc.CheckSpelling End If Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If System.Cursor = wdCursorNormal Exit Sub Case wdAllowOnlyComments Exit Sub End Select Set OriginalRange = Selection.Range System.Cursor = wdCursorWait oDoc.Unprotect oDoc.SpellingChecked = False StatusBar = "Spellchecking document..." For Each oSection In oDoc.Sections If oSection.ProtectedForForms Then Call CheckProtectedSection(oSection) If Cancelled Then Exit For End If Else If oSection.Range.SpellingErrors.Count 0 Then Application.ScreenUpdating = True oSection.Range.CheckSpelling If oSection.Range.SpellingErrors.Count 0 Then Exit For End If End If End If Next oSection oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True OriginalRange.Select Application.ScreenUpdating = True Application.ScreenRefresh If oDoc.Range.SpellingErrors.Count = 0 Then If Options.CheckGrammarWithSpelling Then MsgBox "The spelling and grammar check is complete", _ vbInformation Else MsgBox "The spelling check is complete", vbInformation End If End If |
#15
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
With respect to the current issue being discussed, in my situation, not only
is the bookmark destroyed, but also the FORM FIELD itself. So, I was wondering if it is possible to add some subroutine or code to the original macro to take care of this bug. I know that in Word, under Tools Options Edit menu, there is an option to check off When selecting, automatically select entire word. I was wondering if there can be something to the effect of being able to just select ONLY the word by double-clicking on it, while leaving alone both the bookmark AND the form field. Thanks. -- spassky "Charles Kenyon" wrote: That is the nature of bookmarks. They are very fragile. You are right, it would be nice to be able to double-click on a word and have it not zap the bookmark. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... Ah, we are finally getting to the heart of the problem! It would be nice to be able to simply DOUBLE CLICK on the misspelled word in the Spelling dialog box to select ONLY the word, instead of "painstakingly" highlighting the word by dragging the cursor from the first letter of the word to the last letter and being careful to NOT highlight the bookmarks. Wouldn't it be so much easier to simply double click on the word and have ONLY the word itself and not the bookmarks be selected? So, IS there a way to achieve this? Thanks, once again. spassky "Doug Robbins - Word MVP" wrote: If you are typing the correction into the Spelling dialog, you will need to turn on the display of bookmarks via ToolsOptionsView so that the bookmarks are displayed in the Spelling dialog, and you will need to be careful that YOU do not delete the bookmarks when you enter the corrected spelling. It is NOT the macro that is deleting the bookmarks, it is the OPERATOR. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "jarimura" wrote in message ... I would like to ADD the following to my most recent reply. Not only is the immediately adjacent bookmark brackets lost, the FORM FIELD itself likewise is destroyed, together replaced instead by the corrected word. -- spassky "jarimura" wrote: I tried to insert the code as you recommended. However, I am still running into a problem, whenever the form field is filled in using only ONE word, e.g., "Detroit" in the form field bookmarked City, for instance. Let's say I misspelled "Detroit" "dtrr". When I run the macro, it will recognize the error, and the view box Spelling: English (U.S.) will appear, apparently not only highlighting the misspelled word, but also the immediately adjacent BOOKMARK BRACKETS. When I double click on the error in the view box to select the ENTIRE word, not only is the misspelled word itself highlighted but also the immediately adjacent BOOKMARK BRACKETS as well. When I proceed to input the correction, the corrected word (in this instance, "Detroit" is inserted into the document, but at the same time the bookmark itself is destroyed. So now the referenced field will no longer have bookmark referenced to, and I get a Run-time 424 error. I hope this clarifies the difficulty I am experiencing. Thanks. -- spassky "Doug Robbins - Word MVP" wrote: In my testing, using the macro that is provided on the Word MVP website does not destroy the bookmarks that are assigned either automatically or manually to the formfields via the formfield properties dialog or by using InsertBookmark. If however the spelling of a work in a referenced formfield is corrected, the cross reference is updated. If you insert the following lines of code oDoc.PrintPreview oDoc.ClosePrintPreview before the line oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True the cross references will be updated. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "jarimura" wrote in message ... I wish I could share with you one custom document I had created with numerous form fields, referenced (REF) fields, and bookmarks. So, I will attempt to describe how my form works, short of sending one as an attachment. The document is a actually a template for a physical examination form utilized by the Department of Transportation, containing fields for the individual's name (bookmarked "PatientName"), address (bookmarked "Address"), State (bookmarked "State"), examiner's name (bookmarked "Examiner"), etc. The exam findings, as well as the individual's personal information, are entered into the protected form fields manually. There is a certificate at the end of the exam, with the individual's name, address, state, zip code, examiner's name, etc. As these are redundant information, my form automatically will complete it with the information already entered in the earlier form fields. As the relevant form fields have already been bookmarked, the referenced fields on the certificate are automatically updated accordingly. I have tested the form such that it would do this, even when completely protected, so I can reuse the form over and over. Let's say on the form just described, I misspelled "Detroit" in the protected form field. I would then like to run a macro to check for such misspelling. I came close, using the macro provided, but then I ran into my current problem. By the way, I am running Word 2000, running on Windows XP Professional or Windows 2000 Professional. Thanks, once again. -- spassky "Charles Kenyon" wrote: What is wrong with using the original macro? What is your adaptation? What is it supposed to do for you? (In case you haven't guessed, I didn't trace through your code. If you want someone to do that, I would suggest posting in one of the vba newsgroups rather than this one dealing with document management.) I can tell you that the one on the website has worked fine for me with numerous forms, both as a macro in the form template and as a macro in a global template. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... Doing that only created 2 ADDITIONAL problems, namely (1) the bookmark is destroyed after protecting the document, and (2) the reference field referring back to the bookmark no longer works. PERHAPS, I probably need someone to revise the macro (initially posted). -- spassky "Charles Kenyon" wrote: If your bookmarks are set in the formfield properties do you still have the problem? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I have a document with several form fields that in turn are assigned bookmarks (e.g., PatientName), to allow automatic filling of the referenced fields. This works when the form is protected. However, when I attempted to use the following spell checking macro to check the contents of the form fields themselves (adapted from the macro written by contributed by Dave Rado, Bill Coan, and Astrid Zeelenberg on the MVP website, |
#16
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I believe I found part of the SOLUTION regarding the problem, right from the
website that originally contained the macro (http://word.mvps.org/FAQs/MacrosVBA/...ProtectDoc.htm). In fact, the authors (Dave Rado, Bill Coan, Astrid Zeelenberg, Dan Monk and Geoff Whitfield) did address the issue concerning the inadvertent destruction of the form fields. (See the commentary mentioned throughout the macro, again on their website.) Finally, the article ends with the following statement: Because of the way in which Word's spellcheck dialog works, if any of your formfields are surrounded by (protected) text, some of this text may be displayed in the dialog alongside a spelling error thus allowing the user to modify protected text through the back door the only ways of completely preventing this problem from arising would either be to: a) Have the macro put the result of each formfield, in turn, into a dummy document (or spellcheck window), have the user spellcheck it there, and have the macro put the spellchecked text back into the formfield's result. In order for the user to see what they were spellchecking in context, your macro could tile the form document and the spellcheck window. But this workaround would be clunky. b) Write your own spellcheck dialog (using a UserForm). Both the above solutions are beyond the scope of this site Does anyone know how to go about doing the above? I would especially be interested in option (a). Thanks. -- spassky "jarimura" wrote: With respect to the current issue being discussed, in my situation, not only is the bookmark destroyed, but also the FORM FIELD itself. So, I was wondering if it is possible to add some subroutine or code to the original macro to take care of this bug. I know that in Word, under Tools Options Edit menu, there is an option to check off When selecting, automatically select entire word. I was wondering if there can be something to the effect of being able to just select ONLY the word by double-clicking on it, while leaving alone both the bookmark AND the form field. Thanks. -- spassky "Charles Kenyon" wrote: That is the nature of bookmarks. They are very fragile. You are right, it would be nice to be able to double-click on a word and have it not zap the bookmark. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... Ah, we are finally getting to the heart of the problem! It would be nice to be able to simply DOUBLE CLICK on the misspelled word in the Spelling dialog box to select ONLY the word, instead of "painstakingly" highlighting the word by dragging the cursor from the first letter of the word to the last letter and being careful to NOT highlight the bookmarks. Wouldn't it be so much easier to simply double click on the word and have ONLY the word itself and not the bookmarks be selected? So, IS there a way to achieve this? Thanks, once again. spassky "Doug Robbins - Word MVP" wrote: If you are typing the correction into the Spelling dialog, you will need to turn on the display of bookmarks via ToolsOptionsView so that the bookmarks are displayed in the Spelling dialog, and you will need to be careful that YOU do not delete the bookmarks when you enter the corrected spelling. It is NOT the macro that is deleting the bookmarks, it is the OPERATOR. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "jarimura" wrote in message ... I would like to ADD the following to my most recent reply. Not only is the immediately adjacent bookmark brackets lost, the FORM FIELD itself likewise is destroyed, together replaced instead by the corrected word. -- spassky "jarimura" wrote: I tried to insert the code as you recommended. However, I am still running into a problem, whenever the form field is filled in using only ONE word, e.g., "Detroit" in the form field bookmarked City, for instance. Let's say I misspelled "Detroit" "dtrr". When I run the macro, it will recognize the error, and the view box Spelling: English (U.S.) will appear, apparently not only highlighting the misspelled word, but also the immediately adjacent BOOKMARK BRACKETS. When I double click on the error in the view box to select the ENTIRE word, not only is the misspelled word itself highlighted but also the immediately adjacent BOOKMARK BRACKETS as well. When I proceed to input the correction, the corrected word (in this instance, "Detroit" is inserted into the document, but at the same time the bookmark itself is destroyed. So now the referenced field will no longer have bookmark referenced to, and I get a Run-time 424 error. I hope this clarifies the difficulty I am experiencing. Thanks. -- spassky "Doug Robbins - Word MVP" wrote: In my testing, using the macro that is provided on the Word MVP website does not destroy the bookmarks that are assigned either automatically or manually to the formfields via the formfield properties dialog or by using InsertBookmark. If however the spelling of a work in a referenced formfield is corrected, the cross reference is updated. If you insert the following lines of code oDoc.PrintPreview oDoc.ClosePrintPreview before the line oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True the cross references will be updated. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "jarimura" wrote in message ... I wish I could share with you one custom document I had created with numerous form fields, referenced (REF) fields, and bookmarks. So, I will attempt to describe how my form works, short of sending one as an attachment. The document is a actually a template for a physical examination form utilized by the Department of Transportation, containing fields for the individual's name (bookmarked "PatientName"), address (bookmarked "Address"), State (bookmarked "State"), examiner's name (bookmarked "Examiner"), etc. The exam findings, as well as the individual's personal information, are entered into the protected form fields manually. There is a certificate at the end of the exam, with the individual's name, address, state, zip code, examiner's name, etc. As these are redundant information, my form automatically will complete it with the information already entered in the earlier form fields. As the relevant form fields have already been bookmarked, the referenced fields on the certificate are automatically updated accordingly. I have tested the form such that it would do this, even when completely protected, so I can reuse the form over and over. Let's say on the form just described, I misspelled "Detroit" in the protected form field. I would then like to run a macro to check for such misspelling. I came close, using the macro provided, but then I ran into my current problem. By the way, I am running Word 2000, running on Windows XP Professional or Windows 2000 Professional. Thanks, once again. -- spassky "Charles Kenyon" wrote: What is wrong with using the original macro? What is your adaptation? What is it supposed to do for you? (In case you haven't guessed, I didn't trace through your code. If you want someone to do that, I would suggest posting in one of the vba newsgroups rather than this one dealing with document management.) I can tell you that the one on the website has worked fine for me with numerous forms, both as a macro in the form template and as a macro in a global template. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... Doing that only created 2 ADDITIONAL problems, namely (1) the bookmark is destroyed after protecting the document, and (2) the reference field referring back to the bookmark no longer works. PERHAPS, I probably need someone to revise the macro (initially posted). -- spassky "Charles Kenyon" wrote: If your bookmarks are set in the formfield properties do you still have the problem? -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "jarimura" wrote in message ... I have a document with several form fields that in turn are assigned |