![]() |
|
#16
|
|||
|
|||
![]() This is what I have--the N/R is the one from the Legacy Tools and still has 2 more options and the Choose an item is a content control. The arrow beside it is what I am not seeing in the Legacy drop-down to show the options. |
|
#17
|
|||
|
|||
|
Quote:
|
|
#18
|
||||
|
||||
|
No, but it wouldn't require much effort to re-code for use with the content controls. I'll post back with some later.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#19
|
|||
|
|||
|
Thank you so much, Paul. I will wait for your update and hopefully you can post a code that's based on the document I've attached earlier and then I'll follow your format for the rest of the content control drop-down boxes. You've been very patient--much appreciated.
|
|
#20
|
||||
|
||||
|
Assuming all the dropdowns are meant to have the same conditional shading outcomes, the following code is all you'll need.
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
Dim lClr As Long
With CCtrl
If .Type <> wdContentControlDropdownList Then Exit Sub
With .Range
If .Information(wdWithInTable) = False Then Exit Sub
Select Case .Text
Case "N/R": lClr = wdColorLightTurquoise
Case "Yes": lClr = wdColorPink
Case "No": lClr = wdColorBrightGreen
Case Else: lClr = wdColorAutomatic
End Select
.Cells(1).Range.Shading.BackgroundPatternColor = lClr
End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#21
|
|||
|
|||
|
Quote:
|
|
#22
|
||||
|
||||
|
There are 16,777,216 possible colours, any of which can be specified by using VBA's RGB function. That'd make a pretty big list. That said, the BackgroundPatternColor property comes with a bunch of named presets. You can see what those are by inputting WdColor into the VBE Help screen.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#23
|
|||
|
|||
|
Quote:
|
|
#24
|
||||
|
||||
|
So I'm having a similar issue. I have a Word 2013 document, but I've used the "Rich Text Content Control" button for Data Entry. I've also tried with the Legacy tool box text form. But I can't get them to clear without closing and opening the document. My process is, I type the necessary info, print it, then I want to click a button to reset it (clear all controls) but that Eraser doesn't work, nor does this VBA
Sub ClearFormFields() Dim FF As FormField For Each FF In ActiveDocument.FormFields Select Case FF.Type Case wdFieldFormTextInput FF.Result = "" Case wdFieldFormCheckBox FF.CheckBox.Value = False Case wdFieldFormDropDown FF.DropDown.Value = 1 Case Else ' do nothing End Select Next End Sub Document is not protected, currently saved as a Macro enable Template. |
|
#25
|
||||
|
||||
|
You say you're using the "Rich Text Content Control" button for Data Entry and that the Document is not protected, but your macro is for use with formfields, not content controls, and formfields only work when a document is protected.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Macro to keep formatted form fields after mail merge or replace text with formatted form fields | jer85 | Word VBA | 2 | 04-05-2015 10:00 PM |
Reinstalling Office 2013 after factory reset
|
barryd | Office | 1 | 05-17-2013 04:24 PM |
| Form Fields in Word | jwm1346 | Word | 1 | 04-17-2012 07:02 PM |
Preventing Form Fields to Reset
|
PosseJohn | Word VBA | 4 | 07-15-2011 09:44 PM |
| Form fields in Word messed up | mba | Word VBA | 0 | 02-07-2010 09:54 PM |