#1
|
|||
|
|||
Conditional Outputs from Content Control Dropowns
Hi Paul,
I have a similar situation to https://www.msofficeforums.com/word-...own-lists.html, where i need to place dropdowns in four different parts of the document. Please see the attached screenshot. Do i need to use frames in order to achieve this? If frames are to be used, what code should be used to place drop downs in it. Can you please help me with an example. I've been searching for this from long time, but could not find anything on how to get this work. Thanks Laxman |
#2
|
||||
|
||||
Post #9 of that thread contains the information you need for adding extra sets. And no, you don't need frames.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Hi,
I've Tried using the following code. But it is returning Run time error. Please see attached screen of error. Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Dim i As Long, StrDetails As String With ContentControl If .Title = "Name" Then For i = 1 To .DropdownListEntries.Count If .DropdownListEntries(i).Text = .Range.Text Then StrDetails = Replace(.DropdownListEntries(i).Value, "|", Chr(11)) Exit For End If Next ActiveDocument.SelectContentControlsByTitle("Details").Item(1).Range.Text = StrDetails End If End With End Sub My document is not protected. And i don't understand why i am getting this error. Could you please tell how to fix this? Thanks Laxman |
#4
|
||||
|
||||
You have probably locked the 'Details' control against editing.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
How to unlock To get rid of this error.
|
#6
|
||||
|
||||
Check it's properties! Click on the control, then choose Developer>Controls>Properties
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
In properties of content control, the lock option was already unchecked. Still getting this run time error.
I've attached the word document and code below. Can you please have a look. Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Dim i As Long, StrDetails As String With ContentControl If .Title = "Name1" Then For i = 1 To .DropdownListEntries.Count If .DropdownListEntries(i).Text = .Range.Text Then StrDetails = Replace(.DropdownListEntries(i).Value, "|", Chr(11)) Exit For End If Next ActiveDocument.SelectContentControlsByTitle("Details1").Item(1).Range.Text = StrDetails End If If .Title = "Name2" Then For i = 1 To .DropdownListEntries.Count If .DropdownListEntries(i).Text = .Range.Text Then StrDetails = Replace(.DropdownListEntries(i).Value, "|", Chr(11)) Exit For End If Next ActiveDocument.SelectContentControlsByTitle("Details2").Item(1).Range.Text = StrDetails End If End With End Sub Laxman |
#8
|
||||
|
||||
The reason you're getting the error is that you're using a dropdown content control for the output. You would get better results if you didn't go using different controls from what the sample uses... Use a text content control for the output.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Clicking the selected Content Control checkbox returns wrong control in vba event | DougsGraphics | Word VBA | 2 | 06-24-2015 07:31 AM |
Assign a value to a Content Control | SuzeG | Word VBA | 10 | 12-08-2013 08:04 AM |
Deleting a table from a content control -- preserving the content control | BrainSlugs83 | Word Tables | 8 | 11-14-2013 03:06 AM |
Content control problem | Anja | Word | 2 | 10-16-2013 09:56 AM |
Retrieving content control value | jillapass | Word VBA | 4 | 05-24-2012 05:07 AM |