Microsoft KB Archive/254708: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
 
Line 71: Line 71:
<br />
<br />
In the following sample code</p>
In the following sample code</p>
<pre class="codesample">Keybindings.Add wdKeyCategoryCommand, &quot;Bold&quot;, wdKeyAlt+wdKeyC,wdKeyD
<pre class="codesample">Keybindings.Add wdKeyCategoryCommand, "Bold", wdKeyAlt+wdKeyC,wdKeyD
                         </pre>
                         </pre>
<p>pressing ALT+C,D applies the bold command.<br />
<p>pressing ALT+C,D applies the bold command.<br />
Line 88: Line 88:
<li><p>'''WdKeyCategoryDisable''' may be used to disable hotkeys. The following sample code disables CTRL+K (for inserting a hyperlink) in Microsoft Word:</p>
<li><p>'''WdKeyCategoryDisable''' may be used to disable hotkeys. The following sample code disables CTRL+K (for inserting a hyperlink) in Microsoft Word:</p>
<pre class="codesample">Sub DisableHotKeyInWord()
<pre class="codesample">Sub DisableHotKeyInWord()
     Application.KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyK), KeyCategory:=wdKeyCategoryDisable, Command:=&quot;&quot;
     Application.KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyK), KeyCategory:=wdKeyCategoryDisable, Command:=""
End Sub
End Sub
                     </pre></li>
                     </pre></li>

Latest revision as of 12:53, 21 July 2020

Knowledge Base


WD2000: Undocumented Information About Visual Basic WdKeyCategory Constants

Article ID: 254708

Article Last Modified on 11/23/2006



APPLIES TO

  • Microsoft Word 2000 Standard Edition



This article was previously published under Q254708

SUMMARY

This article provides undocumented information about the Microsoft Visual Basic constants WdKeyCategoryPrefix, WdKeyCategoryDisable, and WdKeyCategoryNil.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

  • WdKeyCategoryPrefix is used in the constant group WdKeyCategory, which is used to add key customizations and look at their properties.

    For example, if you create the custom key combination, ALT+A,B, to map to a command, ALT+A is considered a prefix key customization; it is a prefix to the whole keystroke.

    In the following sample code

    Keybindings.Add wdKeyCategoryCommand, "Bold", wdKeyAlt+wdKeyC,wdKeyD
                            

    pressing ALT+C,D applies the bold command.

    The following code

    MsgBox Keybindings(1).KeyCategory
                            

    returns 1, which is wdKeyCategoryCommand.

    The following code

    MsgBox Application.FindKey(wdKeyAlt+wdKeyC).KeyCategory
                            

    returns 7, which is wdKeyCategoryPrefix.

    NOTE: You never use wdKeyCategoryPrefix when adding a key customization; it is just a side effect.

  • WdKeyCategoryDisable may be used to disable hotkeys. The following sample code disables CTRL+K (for inserting a hyperlink) in Microsoft Word:

    Sub DisableHotKeyInWord()
        Application.KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyK), KeyCategory:=wdKeyCategoryDisable, Command:=""
    End Sub
                        
  • WdKeyCategoryNil is used when a key combination called programmatically does nothing, as in the following sample code:

    Dim oKey as object
    Set oKey = application.findkey(Application.BuildKeyCode(wdKeyControl,
    wdKeyShift, wdKeyX))
    oKey.execute
                            

    NOTE: Using this or similar code that uses the WdKeyCategoryNil constant may cause an unexpected run-time error.


Keywords: kbinfo KB254708