Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-02-2024, 11:01 AM
WordExperto WordExperto is offline Highlight Word formtext next to formcheckbox when selected Windows 10 Highlight Word formtext next to formcheckbox when selected Office 2021
Novice
Highlight Word formtext next to formcheckbox when selected
 
Join Date: Feb 2024
Posts: 4
WordExperto is on a distinguished road
Default Highlight Word formtext next to formcheckbox when selected

Hello everyone and thank you very much in advance.
I have formcheckbox next to formtext and I need the last ones to be highlighted when the first ones are checked.
I have obtained this code but it gives me an error in a protected area and the forms need protection.
How can I do it?



Sub CheckBox_Click()
Dim ff As FormField
Dim rng As Range
Set ff = Selection.FormFields(1) 'Assuming the check box is the only form field in the selection
Set rng = ff.Range 'The range of the check box
rng.MoveEnd wdWord, 1 'Extend the range to include the next word
If ff.CheckBox.Value = True Then 'If the check box is checked
rng.HighlightColorIndex = wdYellow 'Highlight the range with yellow color
Else 'If the check box is unchecked
rng.HighlightColorIndex = wdNoHighlight 'Remove the highlight from the range
End If
End Sub
Reply With Quote
 

Tags
form controls, formcheckbox, formtext



Similar Threads
Thread Thread Starter Forum Replies Last Post
Highlight Word formtext next to formcheckbox when selected VBA word macro to highlight a selected text just like a spell checker Pankaj Word VBA 1 10-14-2016 03:48 AM
Highlight Word formtext next to formcheckbox when selected Word 2010 FormText appears in doc instead of text mp04279 Word 1 02-17-2016 08:16 PM
Highlight Word formtext next to formcheckbox when selected FORMTEXT field contained in INCLUDETEXT bookmark emwinschuh Word 1 08-17-2015 08:55 AM
Macro to find coloured text and replace with form-field/formtext containing that text tarktran Word VBA 1 11-26-2014 08:12 AM
find - reading highlight - highlight all / highlight doesn't stick when saved bobk544 Word 3 04-15-2009 03:31 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:36 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