A utility module:
Private Declare Function GetActiveWindow Lib "USER32" () As Long
Private Declare Function LockWindowUpdate Lib "USER32" (ByVal hwndLock As
Long) As Long
Global gHandle As Long
Public Sub LockWordWindow()
gHandle = GetActiveWindow()
LockWindowUpdate gHandle
End Sub
Public Sub UnlockWordWindow()
LockWindowUpdate 0
End Sub
Private Function IsInCollection(ByVal col As Collection, ByVal fldObjName As
String, ByRef index As Integer) As Boolean
Dim RemoveItem As Boolean
index = 0
RemoveItem = False
For Each Item In col
index = index + 1
If fldObjName = Item.Name Then
RemoveItem = True
Exit For
End If
Next
IsInCollection = RemoveItem
End Function
Public Sub CalculateAvg(ByVal fldObj As FormField, _
ByRef ItemCollection As Collection, ByRef rsltFld As FormField)
Dim RunningTotal As Double
Dim RemoveItem As Boolean
Dim RemoveItemIndex As Integer
RemoveItemIndex = 0
RemoveItem = IsInCollection(ItemCollection, fldObj.Name, RemoveItemIndex)
fldObj.Result = Format(fldObj.Result, "0.0")
If fldObj.Result <> "" Then
If fldObj.Result > 0 Then
ItemCollection.Add Item:=fldObj
End If
End If
If RemoveItem Then
ItemCollection.Remove (RemoveItemIndex)
End If
For Each Item In ItemCollection
RunningTotal = Round(CDbl(RunningTotal) + CDbl(Item.Result), 1)
Next
If RunningTotal > 0 And ItemCollection.Count > 0 Then
rsltFld.Result = Round(RunningTotal / ItemCollection.Count, 1)
Else
rsltFld.Result = CDbl(0)
End If
End Sub
The module with the word fields:
Public CompCollectionCollection As New Collection
Public GoalCollectionCollection As New Collection
Public BehaviorCollectionCollection As New Collection
Sub CompTxt1()
LockWordWindow
Set compField = ActiveDocument.FormFields("CompTxt1")
CalculateAvg compField, CompCollectionCollection,
ActiveDocument.FormFields("CompTxtResults")
SetResultFields
UnlockWordWindow
End Sub
Sub CompTxt2()
LockWordWindow
Set compField = ActiveDocument.FormFields("CompTxt2")
CalculateAvg compField, CompCollectionCollection,
ActiveDocument.FormFields("CompTxtResults")
SetResultFields
UnlockWordWindow
End Sub
Sub CompTxt3()
LockWordWindow
Set compField = ActiveDocument.FormFields("CompTxt3")
CalculateAvg compField, CompCollectionCollection,
ActiveDocument.FormFields("CompTxtResults")
SetResultFields
UnlockWordWindow
End Sub
Sub CompTxt4()
LockWordWindow
Set compField = ActiveDocument.FormFields("CompTxt4")
CalculateAvg compField, CompCollectionCollection,
ActiveDocument.FormFields("CompTxtResults")
SetResultFields
UnlockWordWindow
End Sub
Sub CompTxt5()
LockWordWindow
Set compField = ActiveDocument.FormFields("CompTxt5")
CalculateAvg compField, CompCollectionCollection,
ActiveDocument.FormFields("CompTxtResults")
SetResultFields
UnlockWordWindow
End Sub
Sub CompTxt6()
LockWordWindow
Set compField = ActiveDocument.FormFields("CompTxt6")
CalculateAvg compField, CompCollectionCollection,
ActiveDocument.FormFields("CompTxtResults")
SetResultFields
UnlockWordWindow
End Sub
Sub CompTxt7()
LockWordWindow
Set compField = ActiveDocument.FormFields("CompTxt7")
CalculateAvg compField, CompCollectionCollection,
ActiveDocument.FormFields("CompTxtResults")
SetResultFields
UnlockWordWindow
End Sub
Sub CompTxt8()
LockWordWindow
Set compField = ActiveDocument.FormFields("CompTxt8")
CalculateAvg compField, CompCollectionCollection,
ActiveDocument.FormFields("CompTxtResults")
SetResultFields
UnlockWordWindow
End Sub
Sub CompTxt9()
LockWordWindow
Set compField = ActiveDocument.FormFields("CompTxt9")
CalculateAvg compField, CompCollectionCollection,
ActiveDocument.FormFields("CompTxtResults")
'SetResultFields
UnlockWordWindow
End Sub
Sub GoalTxt1()
LockWordWindow
Set compField = ActiveDocument.FormFields("GoalTxt1")
CalculateAvg compField, GoalCollectionCollection,
ActiveDocument.FormFields("GoalAvgRslts")
SetResultFields
UnlockWordWindow
End Sub
Sub GoalTxt2()
LockWordWindow
Set compField = ActiveDocument.FormFields("GoalTxt2")
CalculateAvg compField, GoalCollectionCollection,
ActiveDocument.FormFields("GoalAvgRslts")
SetResultFields
UnlockWordWindow
End Sub
Sub GoalTxt3()
LockWordWindow
Set compField = ActiveDocument.FormFields("GoalTxt3")
CalculateAvg compField, GoalCollectionCollection,
ActiveDocument.FormFields("GoalAvgRslts")
SetResultFields
UnlockWordWindow
End Sub
Sub GoalTxt4()
LockWordWindow
Set compField = ActiveDocument.FormFields("GoalTxt4")
CalculateAvg compField, GoalCollectionCollection,
ActiveDocument.FormFields("GoalAvgRslts")
SetResultFields
UnlockWordWindow
End Sub
Sub GoalTxt5()
LockWordWindow
Set compField = ActiveDocument.FormFields("GoalTxt5")
CalculateAvg compField, GoalCollectionCollection,
ActiveDocument.FormFields("GoalAvgRslts")
SetResultFields
UnlockWordWindow
End Sub
Sub BehaviorTxt1()
LockWordWindow
Set compField = ActiveDocument.FormFields("BehaviorTxt1")
CalculateAvg compField, BehaviorCollectionCollection,
ActiveDocument.FormFields("BehaviorAvgRslts")
SetResultFields
UnlockWordWindow
End Sub
Sub BehaviorTxt2()
LockWordWindow
Set compField = ActiveDocument.FormFields("BehaviorTxt2")
CalculateAvg compField, BehaviorCollectionCollection,
ActiveDocument.FormFields("BehaviorAvgRslts")
SetResultFields
UnlockWordWindow
End Sub
Sub BehaviorTxt3()
LockWordWindow
Set compField = ActiveDocument.FormFields("BehaviorTxt3")
CalculateAvg compField, BehaviorCollectionCollection,
ActiveDocument.FormFields("BehaviorAvgRslts")
SetResultFields
UnlockWordWindow
End Sub
Sub BehaviorTxt4()
LockWordWindow
Set compField = ActiveDocument.FormFields("BehaviorTxt4")
CalculateAvg compField, BehaviorCollectionCollection,
ActiveDocument.FormFields("BehaviorAvgRslts")
SetResultFields
UnlockWordWindow
End Sub
Sub BehaviorTxt5()
LockWordWindow
Set compField = ActiveDocument.FormFields("BehaviorTxt5")
CalculateAvg compField, BehaviorCollectionCollection,
ActiveDocument.FormFields("BehaviorAvgRslts")
SetResultFields
UnlockWordWindow
End Sub
Another utilitly module:
Public Sub SetResultFields()
ActiveDocument.FormFields("FinalCompRslts").Result =
ActiveDocument.FormFields("CompTxtResults").Result
ActiveDocument.FormFields("GoalFinalRslts").Result =
ActiveDocument.FormFields("GoalAvgRslts").Result
ActiveDocument.FormFields("TotalCompCalc").Result =
CDbl(ActiveDocument.FormFields("FinalCompRslts").Result) * 0.5
ActiveDocument.FormFields("TotalGoalCalc").Result =
CDbl(ActiveDocument.FormFields("GoalFinalRslts").Result) * 0.5
ActiveDocument.FormFields("TotalOverAllScore").Result =
CDbl(ActiveDocument.FormFields("TotalCompCalc").Result) +
CDbl(ActiveDocument.FormFields("TotalGoalCalc").Result)
End Sub
In your first post, you said you worte some macros. Did you put any of them
into the ThisDocument module? If so, edit that macro and examine it for
[quoted text clipped - 42 lines]