Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-15-2015, 06:58 PM
macropod's Avatar
macropod macropod is offline Can't reset form fields (Word 2013) and conditional formatting Windows 7 64bit Can't reset form fields (Word 2013) and conditional formatting Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,536
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default


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]
Reply With Quote
  #2  
Old 10-15-2015, 07:15 PM
rogelinepaula rogelinepaula is offline Can't reset form fields (Word 2013) and conditional formatting Windows 8 Can't reset form fields (Word 2013) and conditional formatting Office 2013
Novice
Can't reset form fields (Word 2013) and conditional formatting
 
Join Date: May 2015
Posts: 22
rogelinepaula is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
See attached. Assuming all the dropdowns are meant to have the same conditional shading outcomes, the included code is all you'll need.
WOW! Thank you so much, Paul! Yes--all the options are meant to have the same shadings. I'll just add the other options and will assign a color. My last question--do you have a link or a quick reference of the list of colors that I can use in VBA? I COULDN'T THANK YOU ENOUGH FOR ALL YOUR HELP.
Reply With Quote
  #3  
Old 10-15-2015, 07:33 PM
macropod's Avatar
macropod macropod is offline Can't reset form fields (Word 2013) and conditional formatting Windows 7 64bit Can't reset form fields (Word 2013) and conditional formatting Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,536
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by rogelinepaula View Post
do you have a link or a quick reference of the list of colors that I can use in VBA?
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]
Reply With Quote
  #4  
Old 10-15-2015, 10:00 PM
rogelinepaula rogelinepaula is offline Can't reset form fields (Word 2013) and conditional formatting Windows 8 Can't reset form fields (Word 2013) and conditional formatting Office 2013
Novice
Can't reset form fields (Word 2013) and conditional formatting
 
Join Date: May 2015
Posts: 22
rogelinepaula is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
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.
Many thanks for all your help, Paul! And to those who have replied as well. Closing this case now. Glad to be part of this community.
Reply With Quote
  #5  
Old 01-07-2016, 02:44 PM
Maria Hernandez's Avatar
Maria Hernandez Maria Hernandez is offline Can't reset form fields (Word 2013) and conditional formatting Windows 7 32bit Can't reset form fields (Word 2013) and conditional formatting Office 2013
Novice
 
Join Date: Jan 2016
Location: Bakersfield, CA
Posts: 1
Maria Hernandez is on a distinguished road
Default

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.
Reply With Quote
  #6  
Old 01-07-2016, 03:54 PM
macropod's Avatar
macropod macropod is offline Can't reset form fields (Word 2013) and conditional formatting Windows 7 64bit Can't reset form fields (Word 2013) and conditional formatting Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,536
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply



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
Can't reset form fields (Word 2013) and conditional formatting 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
Can't reset form fields (Word 2013) and conditional formatting 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

Other Forums: Access Forums

All times are GMT -7. The time now is 09:27 PM.


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