Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-09-2024, 03:16 AM
Kev3702 Kev3702 is offline Macro required Windows 10 Macro required Office 2021
Novice
Macro required
 
Join Date: Jan 2024
Posts: 5
Kev3702 is on a distinguished road
Default Macro required


Hi all, I am a complete noob here and my Office word skills are limited, so I really am hoping for some help.

I have created a medium sized how to guide in a word document utilising bookmarks and Hyperlinks. Clicking on the hyperlink takes you to a said area in the document. The area of text needs to be highlighted in bold or a colour to identify the text when the hyperlink is clicked.

I have spent a few wks looking for ways around this, but I can't find anything. A Macro seems the best way to implement this. Is anyone able to assist and maybe supply me with a Macro that would fix this issue. Cheers
Reply With Quote
  #2  
Old 01-09-2024, 09:33 AM
June7's Avatar
June7 June7 is offline Macro required Windows 10 Macro required Office 2010
Novice
 
Join Date: Nov 2023
Posts: 20
June7 is on a distinguished road
Default

What do you mean by "area' and "the text" - a header, a paragraph, a chapter?
Reply With Quote
  #3  
Old 01-09-2024, 10:24 AM
Kev3702 Kev3702 is offline Macro required Windows 10 Macro required Office 2021
Novice
Macro required
 
Join Date: Jan 2024
Posts: 5
Kev3702 is on a distinguished road
Default

June7 cheers for the reply. The document has several tables within it, which are not uniform throughout the doc. I need to highlight various parts of the tables throughout the doc, providing formating details for users of said areas. These are highlighted via hyperlinks and bookmarks. Hopefully that provides a better picture.
Reply With Quote
  #4  
Old 01-09-2024, 05:08 PM
Guessed's Avatar
Guessed Guessed is offline Macro required Windows 10 Macro required Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
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
  #5  
Old 01-11-2024, 07:23 AM
Kev3702 Kev3702 is offline Macro required Windows 10 Macro required Office 2021
Novice
Macro required
 
Join Date: Jan 2024
Posts: 5
Kev3702 is on a distinguished road
Default

Guessed, thank you so much for your time. Unfortunately I can't get the macro to work. Any chance I can forward you a similar scenario of what I am trying to do. No worries at all if that's not possible. Hopefully then you can tell me where I am going wrong.
Reply With Quote
  #6  
Old 01-11-2024, 03:48 PM
Guessed's Avatar
Guessed Guessed is offline Macro required Windows 10 Macro required Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
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

I sent you a private message if you wanted to email the file to me for checking.

The code I supplied must go into the ThisDocument module for it to work. Then it is simply a case of adding rich text content controls around the text you want to highlight whenever the selection is inside that range.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #7  
Old 01-15-2024, 01:19 AM
Kev3702 Kev3702 is offline Macro required Windows 10 Macro required Office 2021
Novice
Macro required
 
Join Date: Jan 2024
Posts: 5
Kev3702 is on a distinguished road
Default

Guessed I have replied, just incase it has gone into your junk folder 👍
Reply With Quote
  #8  
Old 01-16-2024, 03:33 PM
Guessed's Avatar
Guessed Guessed is offline Macro required Windows 10 Macro required Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
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

Sorry for the slow response. I've been away on holidays.

Looking at your sample doc, the first thing I noticed was that you didn't place either of macros in the ThisDocument module as I said you needed to in both above posts. You might have more success if you try that.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #9  
Old 01-24-2024, 01:40 PM
Kev3702 Kev3702 is offline Macro required Windows 10 Macro required Office 2021
Novice
Macro required
 
Join Date: Jan 2024
Posts: 5
Kev3702 is on a distinguished road
Default

Guessed, pinged you an email. If this is not possible can you let me know, so I can try something else 👍.
Reply With Quote
  #10  
Old 01-24-2024, 03:13 PM
Guessed's Avatar
Guessed Guessed is offline Macro required Windows 10 Macro required Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
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

Put the macros in your ThisDocument Module as I've already advised.

Put the Content Control around the range you indicated with your bookmarks. Then collapse the bookmarks to be positioned after the first character inside the Content Control.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
documents print setup defined in page setup, but overriden by printer settings. macro required? Rosemary Word VBA 6 02-18-2021 11:10 PM
Macro required Help with some VBA code Required dmcg9760 Excel Programming 9 03-01-2016 03:59 PM
Excel 2007 - formula or macro/vba code required wrighty50 Excel Programming 3 05-13-2012 02:24 PM
Macro or routine required evanhughes Outlook 0 11-18-2011 02:56 AM
Suggestion required domex Word 0 10-06-2010 05:35 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:41 AM.


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