![]() |
|
#1
|
|||
|
|||
![]()
In this code when I click check box button it shows list of items. For example in "Spouse of employee" table it shows( First Name; Last Name; Phone number and etc). And even if I want to add different items for each tables after updating page all items take a value of first table "Employee". But I do not need it.
I need only drop down function with help of check box, it runs perfect. But the value of each tables must be different, I will type value.( for example, in "Spouse of Employee" list of items must be: First name of Spouse; Last Name of Spouse and etc. and it the value must be different, now it just copy value from 'Employee table") Where in this code do I need change function and which Function? Thank you in advance.! |
#2
|
|||
|
|||
![]()
Can Somebody help me please??
Gmayor? ![]() |
#3
|
||||
|
||||
![]()
How about some patience on your part... You're not paying anyone here to do your coding!
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
![]() Quote:
I just forget to write it one my first message and add it separately. ![]() ![]() |
#5
|
||||
|
||||
![]()
Try:
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean) Dim Tbl As Table, Rng As Range, i As Long Dim oCCtrl As ContentControl With CCtrl i = ActiveDocument.Range(0, .Range.Tables(1).Range.End).Tables.Count Select Case .Title Case "Spouse" If .Checked = True Then MsgBox "Adding spouse section" Set Rng = .Range.Tables(1).Range Call AddGroup(Rng, i) Else MsgBox "Removing spouse section" Set Rng = ActiveDocument.Tables(i + 1).Range Call RemoveGroup(Rng) End If Case "Child1" If .Checked = True Then MsgBox "Adding child section" Set Rng = .Range.Tables(1).Range Call AddGroup(Rng, i) Else MsgBox "Removing child section" Set Rng = ActiveDocument.Tables(i + 1).Range Call RemoveGroup(Rng) End If End Select End With End Sub Sub AddGroup(Rng As Range, i As Long) Dim CCtrl As ContentControl, t As Long, bAdd As Boolean bAdd = False If (i = ActiveDocument.Tables.Count) Then bAdd = True If bAdd = False Then If ActiveDocument.Tables(i + 1).Rows.Count = 1 Then bAdd = True End If If bAdd = True Then With Rng .Collapse 0 .Text = vbCr .Collapse 0 .FormattedText = ActiveDocument.Tables(2).Range.FormattedText For Each CCtrl In .ContentControls With CCtrl t = .Type .Type = wdContentControlText .Range.Text = "" .Type = t End With Next End With End If End Sub Sub RemoveGroup(Rng As Range) Dim CCtrl As ContentControl With Rng If .Tables(1).Rows.Count > 1 Then For Each CCtrl In .ContentControls CCtrl.LockContentControl = False Next .End = .End + 1 .Delete End If End With End Sub I'll leave it to you to figure out what to do for those with more than one spouse and/or child... PS: When posting code, please use the code tags, indicated by the # button on the posting menu. Without them, your code loses much of whatever structure it had.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
![]()
Thank you for answer.
How can I run it? I replaced my old code for this one. but it doesn't work |
#7
|
||||
|
||||
![]()
The code works just fine - I actually developed and tested it in your document...
What's wrong??? You ask a question, then less than two hours later bump the post with a "Can Somebody help me please??". That's what's wrong. Keep up the behaviour you've exhibited so far and you'll find no-one here willing to help you.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
digiart | Word VBA | 1 | 08-25-2017 10:17 PM |
Lock items in a table | village | Word | 2 | 06-22-2017 07:33 AM |
Select multiple items from a drop down list | ConfuddledOne | Excel Programming | 0 | 01-30-2017 08:13 PM |
![]() |
supremegrandruler | Word | 1 | 12-09-2014 03:17 PM |
Drag and Drop Outlook Items to Word | Mike23 | Outlook | 0 | 06-14-2010 03:51 PM |