0

I have a Word form that I am working on.

It has one field that is supposed to be calculated from other fields.

In the prior iteration, you could click the cell in the table and hit F9 and the field would update.

I have since added some other buttons and VBA and now you can no longer click the cell when "Restrict Editing" is on.

I have tried a button tied to VBA that will update all fields, but when you click that button, you cannot edit any of the fields.

How can I update this field, and still be able to manually update my other fields?

1 Answer 1

0

The problem was that Content Controls and ActiveX buttons are not altogether compatible. Also, the programmer I had inherited the form from was using a simple field calculation based on the table in the document instead of VBA. I was able to come up with a better solution. I used the sub:

Private Sub Document_ContentControlOnExit(ByVal thisControl As ContentControl, Cancel As Boolean)    
End Sub

to execute code onExit from the controls. This function executes on ALL Content Controls as the user exits the Content Control. Another tool I developed was the following function which will find the index of the control with the given title:

'Function to get control index given the control title
'PARAMETER Control Title as String
'RETURN Control Index as Integer
Public Function GetControlIndex(ccTitle As String) As Integer
    'Function Variable Declaration
    Dim objCC As ContentControl

    'look at each ContentControl
    For i = 1 To ActiveDocument.ContentControls.count
        Set objCC = ActiveDocument.ContentControls.Item(i)
        With objCC
            If .Title = ccTitle Then
                GetControlIndex = i
            End If
        End With
    Next i
End Function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.