#How to create a shortcut for bold in word code#
In the Code Editor, replace the contents of the Ribbon XML file with the following code.
The Ribbon xml file opens in the Code Editor. By default, the Ribbon XML file is named Ribbon1.xml. In Solution Explorer, select the Ribbon XML file. Protected Overrides Function CreateRibbonExtensibilityObject() As protected override CreateRibbonExtensibilityObject() This code overrides the CreateRibbonExtensibilityObject method and returns the Ribbon XML class to the Office application. The ThisDocument class file opens in the Code Editor.Īdd the following code to the ThisDocument class. In Solution Explorer, select ThisDocument.cs or ThisDocument.vb. For more information, see How to: Get started customizing the ribbon. To add commands to a shortcut menuĪdd a Ribbon XML item to the project. You can write code in the BeforeRightClick event of the bookmark so that when the user right-clicks the text in the bookmark, a shortcut menu appears.Īdd buttons to the shortcut menu that appears when you right-click the document. You can program against several events of the bookmark. When you add a bookmark to a document at design time, a Bookmark control is created. The words "right-click the text" are in both bookmark1 and bookmark2. Select the words "creating a shortcut menu when you right-click the text", and then click OK.Īdd another Bookmark control to the words "right-click the text in a bookmark". The Add Bookmark Control dialog box appears. In the Toolbox, from the Word Controls tab, drag a Bookmark control to your document. To add a Bookmark control to your document This is an example of creating a shortcut menu when you right-click the text in a bookmark. In the document that appears in the designer of your project, type the following text. Visual Studio opens the new Word document in the designer and adds the My Bookmark Shortcut Menu project to Solution Explorer.Īdd some text to your document and then add two overlapping bookmarks. For more information, see How to: Create Office projects in Visual Studio. In the wizard, select Create a new document. To create a new projectĬreate a Word document project that has the name My Bookmark Shortcut Menu. The first step is to create a Word document project in Visual Studio. For more information, see Configure a computer to develop Office solutions. You need the following components to complete this walkthrough:Īn edition of Visual Studio that includes the Microsoft Office developer tools. For more information, see Personalize the IDE. The Visual Studio edition that you have and the settings that you use determine these elements.
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions.