Thread: Macro required
View Single Post
 
Old 01-09-2024, 05:08 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Yes, it does sound like a job for a macro but there likely would need to be more than one macro.

Say for example, clicking on something runs a macro and the target content gets highlighted in Bold before the macro ends. Then the user moves the selection point - but the bolded text would remain bolded because there isn't a command to change it back as the selection moves away.

Perhaps the de-selecting could happen automatically if the target area was defined with a Content Control as well as a bookmark. Then an OnExit macro could be implemented. For instance, if you place Rich Text Content Controls around some text, you can put these macros in your ThisDocument module.
Code:
Private Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl)
  ContentControl.Range.Font.Bold = True
  ContentControl.Color = wdColorAqua
End Sub

Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
  ContentControl.Range.Font.Reset
  ContentControl.Color = wdColorWhite
End Sub
The bookmark shouldn't define the entire text in the ContentControl, just be contained somewhere inside it.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote