Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-07-2013, 01:11 PM
SuzeG SuzeG is offline Assign a value to a Content Control Windows 7 64bit Assign a value to a Content Control Office 2010 64bit
Novice
Assign a value to a Content Control
 
Join Date: Dec 2013
Location: Va Beach
Posts: 21
SuzeG is on a distinguished road
Default

Awesome - I am trying to use the example you sent in the .zip file.
This is the 2nd table in the form so I changed the line
With ActiveDocument.Tables(1) to (2)
but when I go to try the form I get stopped at the code line
With .Cell(i, 2).Range.ContentControls(1)
I am not sure what that line is referring to.



Thank you for your help. I am trying my best to understand the code by reading in the VBA Word Help but it is a bit confusing for a novice.

The code in the .zip is below just to refresh your memory.
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim i As Long, j As Long, k As Long, l As Long
With ActiveDocument.Tables(2)
  If ContentControl.Range.InRange(.Range) Then
    For i = 1 To .Rows.Count - 1
      With .Cell(i, 2).Range.ContentControls(1)
        If .Range.Text <> .PlaceholderText Then
          k = k + 1
          For j = 1 To .DropdownListEntries.Count
            If .DropdownListEntries(j) = .Range.Text Then
              l = l + .DropdownListEntries(j).Value
              Exit For
            End If
          Next
        End If
      End With
    Next
    With .Rows.Last.Cells(2).Range
      If k > 0 Then
        .Text = Format(l / k, "0.00")
      Else
        .Text = vbNullString
      End If
    End With
  End If
End With 
End Sub

Last edited by macropod; 12-07-2013 at 01:38 PM. Reason: Added code tags & formatting
Reply With Quote
Reply

Tags
content controls, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Assign a value to a Content Control Move to next content control cksm4 Word VBA 13 07-02-2019 07:48 PM
Assign a value to a Content Control Deleting a table from a content control -- preserving the content control BrainSlugs83 Word Tables 8 11-14-2013 03:06 AM
Assign a value to a Content Control Content control problem Anja Word 2 10-16-2013 09:56 AM
Assign a value to a Content Control Hierarchical content control ntjson Word VBA 1 04-04-2013 12:07 AM
Assign a value to a Content Control Content control titles jillapass Word VBA 3 05-29-2012 06:11 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:13 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft