Visual Basic opening when word macro is initiated

T

trex3648

I have written several VBA macros that are initiated when the cursor leaves
a field inserted into a Word form. When this happends Visual Basic
automatically opens. How can I keep Visual Basic from opening when this
happends.
 
J

Jay Freedman

trex3648 said:
I have written several VBA macros that are initiated when the cursor
leaves a field inserted into a Word form. When this happends Visual
Basic automatically opens. How can I keep Visual Basic from opening
when this happends.

The VBA editor is probably opening because there is an error in one or more
of the macros, and it's showing you where the error is. Does it highlight
one of the lines in yellow? If so, that line contains the error. There is
usually also a message box saying what the error is -- if so, exactly what
does it say?

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
T

trex3648

When I use the macros in Windows 2000 Office 2000 and in Windows XP
Professional and Office 2007 I get no errors. But when the user uses them in
Windows XP and Office 2002 over their intranet site they are instructed to
save the file and re-open in word instead of the browser but the error still
occurs.

When they open the form they get Microsoft Visual Basic dialog Error box
that states: Compile error in hidden module: ThisDocument.

It does an autosave and reopens in word. They get the first error message
again.

Some users are able to tab through.


If they click in the field with the macros they get the 'Send' and 'Don't
Send' dialog box.

Any ideas?





Than you Brian!
 
T

trex3648

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
 
J

John Crews

Jay,

I was analyzing the macro code and found this in the Microsoft Word Objects
ThisDocument. I think this might be the problem. This code might not be
capatible with Office XP 2002. I have e-mailed the document back to the
customer with out the below code in the macro. I will let you know. Thanks
for you assistance.

'Private Sub Document_Open()
'ActiveWindow.View.ReadingLayout = Not ActiveWindow.View.ReadingLayout
'If ThisDocument.ProtectionType <> wdAllowOnlyFormFields Then
' ThisDocument.Protect wdAllowOnlyFormFields, , "hcdeval"
'End If
'End Sub
 
F

fumei via OfficeKB.com

Just as a comment, when actioning a number of formfields (or any other
collection of objects), it often makes for easier writing (and reading) if
you use an object of the collection. So instead of:

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

you could use:

Sub SetResultFields()
Dim DocFF As FormFields
Set DocFF = ActiveDocument.FormFields

DocFF("FinalCompRslts").Result = DocFF("CompTxtResults").Result
DocFF("GoalFinalRslts").Result = DocFF("GoalAvgRslts").Result
DocFF("TotalCompCalc").Result = CDbl(DocFF("FinalCompRslts").Result) * 0.5
DocFF("TotalGoalCalc").Result = CDbl(DocFF("GoalFinalRslts").Result) * 0.5
DocFF("TotalOverAllScore").Result = CDbl(DocFF("TotalCompCalc").Result) +
_
CDbl(DocFF("TotalGoalCalc").Result)
End Sub

By making an object of ALL the formfields (DocFF), you can use THAT, instead
of all those ActiveDocument.Formfields.
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]
 
J

John Crews

Great tip...thank you very much

fumei via OfficeKB.com said:
Just as a comment, when actioning a number of formfields (or any other
collection of objects), it often makes for easier writing (and reading) if
you use an object of the collection. So instead of:

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

you could use:

Sub SetResultFields()
Dim DocFF As FormFields
Set DocFF = ActiveDocument.FormFields

DocFF("FinalCompRslts").Result = DocFF("CompTxtResults").Result
DocFF("GoalFinalRslts").Result = DocFF("GoalAvgRslts").Result
DocFF("TotalCompCalc").Result = CDbl(DocFF("FinalCompRslts").Result) *
0.5
DocFF("TotalGoalCalc").Result = CDbl(DocFF("GoalFinalRslts").Result) *
0.5
DocFF("TotalOverAllScore").Result = CDbl(DocFF("TotalCompCalc").Result)
+
_
CDbl(DocFF("TotalGoalCalc").Result)
End Sub

By making an object of ALL the formfields (DocFF), you can use THAT,
instead
of all those ActiveDocument.Formfields.
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]
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

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