KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: How to create a command to remove highlight from a selection in Microsoft Word?
Topic Summary:
Created On: 11/12/2021 01:08 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 11/12/2021 01:08 PM
User is offline View Users Profile Print this message

Author Icon
wristofdoom
Top-Tier Member

Posts: 323
Joined: 09/03/2020

I have a Microsoft Word command called "remove highlight" that makes use of the "alt" hotkeys and the Word command ribbon. So my command was as follows:

 

Sub Main
    SendKeys "%h"
    Wait 0.1
    SendKeys "i"
    Wait 0.1
    SendKeys "n"
End Sub

But now I have a conflicting command from an Autohotkey script that uses %h.

 

I don't want to disable this Autohotkey script, because it's useful in Microsoft Word as well as in other contexts. 

 

So I'm wondering, is there a more direct way  to activate the "remove highlight" function in Microsoft Word?



I looked through the hotkeys in Microsoft Word, but I can't find one that maps directly to removing a highlight.

 

I would love to program the remove highlight function in Microsoft Word to some hotkey, like ^%+h and then be able to activate it via both my voice command and the keyboard.

 



-------------------------

Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017.

 11/12/2021 02:49 PM
User is offline View Users Profile Print this message

Author Icon
Matt_Chambers
Top-Tier Member

Posts: 569
Joined: 08/09/2018

Looking back through my old commands, I see this:

Selection.Range.HighlightColorIndex=wdNoHighlight

You could create a Microsoft Word macro, using that text, and assign a hot key combination to it.

You also could use an Advanced Scripting command, using the same language, with a reference to the Microsoft Word object library.

Disclaimer: I haven't used this command in quite a few years. I expect it still works, but no guarantees.
 11/12/2021 03:09 PM
User is offline View Users Profile Print this message

Author Icon
wristofdoom
Top-Tier Member

Posts: 323
Joined: 09/03/2020

Thanks--Not sure about this part.

> with a reference to the Microsoft Word object library.

I have heard about this but don't know how to lookup what that looks like.


Sub Main
{ some "reference" code here? }
Selection.Range.HighlightColorIndex=wdNoHighlight
End Sub

Something like this?

-------------------------

Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017.

 11/12/2021 03:48 PM
User is offline View Users Profile Print this message

Author Icon
Matt_Chambers
Top-Tier Member

Posts: 569
Joined: 08/09/2018

In the MyCommands Editor, with the cursor in the Script field, say "press alt enter". After a few seconds, you will get a box with a long list of possible object references. You need to scroll all the way down to Microsoft Word and check the box for that.

You won't see any reference code in your actual script, unfortunately.
 11/12/2021 08:09 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4313
Joined: 12/08/2007

Instead of Alt+H, try Alt followed by H, or even better, F10 followed by H:



Sub Main
SendKeys "{F10}"
Wait 0.1 ' This delay may or may not be necessary
SendKeys "h"
Wait 0.1
SendKeys "i"
Wait 0.1
SendKeys "n"
End Sub
 11/15/2021 06:49 PM
User is offline View Users Profile Print this message

Author Icon
wristofdoom
Top-Tier Member

Posts: 323
Joined: 09/03/2020


Thanks. Very useful. I've added instructions for how to do this to my public notes.

https://publish.obsidian.md/arun/Tech/Dictation/How+to+Reference+and+Use+the+Microsoft+Word+Object+Library+in+Dragon



-------------------------

Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017.



 11/16/2021 11:11 AM
User is offline View Users Profile Print this message

Author Icon
Matt_Chambers
Top-Tier Member

Posts: 569
Joined: 08/09/2018

yes, it's very useful. When I used to work regularly in Microsoft Word, I triggered all sorts of Microsoft Word macros using the object library reference. It was about the only thing that made using Microsoft Word bearable.

Statistics
32306 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 0 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 361 guests browsing this forum, which makes a total of 361 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2022 FuseTalk™ Inc. All rights reserved.