Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 10-15-2015, 03:49 AM
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,521
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

As coded, the macro in the link is for just a single table cell. To work with multiple dropdowns, you could use code like:
Code:
Dim lTbl As Long, lRow As Long, lCol As Long, lClr As Long
Const StrPwd As String = ""
 
Sub ConditionalFormat()
With ActiveDocument
  If .ProtectionType = wdAllowOnlyFormFields Then .Unprotect , StrPwd
  .Tables(lTbl).Cell(lRow, lCol).Range.Shading.BackgroundPatternColor = lClr
  .Protect wdAllowOnlyFormFields, True, NoReset:=True, Password:=StrPwd
End With
End Sub
called by an on-exit macro attached to each formfield coded along the lines of:
Code:
Sub DD1Fmt()
With ActiveDocument.FormFields("Dropdown1")
  lTbl = ActiveDocument.Range(0, .Range.End).Tables.Count
  lRow = .Range.Cells(1).RowIndex
  lCol = .Range.Cells(1).ColumnIndex
  Select Case .Result
    Case "Unknown": lClr = wdColorPink
    Case "Yes": lClr = wdColorLightBlue
    Case "No": lClr = wdColorBrightGreen
    Case Else: lClr = wdColorYellow
  End Select
  Call ConditionalFormat
End With
End Sub
Simply change this latter sub's name and dropdown reference for each calling dropdown.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



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 12:23 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