UPdate macro for spell check

K

Kay

I am using the suggested spell check macro for a form so I will not lose the
filled in field data. I thought that it would also update the document for
reference fields and table formulas. It does not seem to do
that...espescially with formulas. Is there more code I can use to have the
macro do all of that for me.
Sub FormsSpellCheck()

' If document is protected, Unprotect it.
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:="not2day"
End If

' Set the language for the document.
Selection.WholeStory
Selection.LanguageID = wdEnglishUS

' Perform Spelling/Grammar check.
If Options.CheckGrammarWithSpelling = True Then
ActiveDocument.CheckGrammar
Else
ActiveDocument.CheckSpelling
End If

' ReProtect the document.
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End If

End Sub
 
G

Graham Mayor

For the formulae you may not need to do anything more than check the
calculate on excit check boxes of the form fields that contribute to the
calculation. Usually only REF fields in headers need a little more
encouragement. For those you can add in the sample code at
http://www.gmayor.com/installing_macro.htm to update the fields.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
K

Kay

Graham,

thank you...this doc has been quite the challenge. I will add the code in
for ref fields and such but while I thoroughly understand how to use the
formulas or calculated fields in word tables...for some reason, the formulas
do not update. I have checked calculate on exit, I have recreated the fields
a dozen times and so on. I make sure that 0 shows in the fields just in case
one field might not be filled in. Of course, if the doc is protected, you
can't Select All and strike F9. We are trying to dummy proof this and there
is such resistance to even having someone right click and update. So I
created a macro to update on exit from the field which works for the first
row of calculations, but the next row is a field that get the values for its
formula from the first calculated row as well as other cells in the table.
The macro will not update that row, even though I programmed it to select
both rows and then reprogrammed to update the first, then go to the second,
select row and update. It just goes on and on. THe project manager wanted
all of his objectives met without using vb....good luck. The next challenge
involves having the enduser insert another completed form into this main
form...not difficult, except all of the numbered styles change to "continued
numbering" and once again because of the protection you cannot change that
using standard techniques.

Anyway, thank you for your help. I will add in that line of code.
 
K

Kay

Well here I am again...I have made changes to the macro to reset the password
and it works fine, but the code that was suggested for updating the fields,
resets all of my form fields and doesn't update the reference fields anyway.
I cannot find any broken lines. The code is as follows:
Sub FormsSpellCheck()

' If document is protected, Unprotect it.
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:="not2day"
End If

' Set the language for the document.
Selection.WholeStory
Selection.LanguageID = wdEnglishUS

' Perform Spelling/Grammar check.
If Options.CheckGrammarWithSpelling = True Then
ActiveDocument.CheckGrammar
Else
ActiveDocument.CheckSpelling
End If
' Perform UPdate of reference fields
Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
oStory.Fields.Update
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory
Set oStory = Nothing

' ReProtect the document.
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True,
Password:="not2day"

End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top