Skip to Main Content
Visual Studio Hacks
book

Visual Studio Hacks

by James Avery
March 2005
Intermediate to advanced content levelIntermediate to advanced
304 pages
19h 23m
English
O'Reilly Media, Inc.
Content preview from Visual Studio Hacks
Create a Command Bar in Word 2003 #84
Chapter 11, Visual Studio Tools for Office
|
369
HACK
Create the Command Bar
When the wizard has completed, you will be placed into the main code file
named ThisDocument.cs. Most of your code will execute when a user cre-
ates a new instance of your document. This event is handled by the follow-
ing method:
protected void ThisDocument_New( )
{
}
At this point, you are going to need to create some class-level variables to
work with as you build your command bar. The main class is
OfficeCodeBehind, so your code should look something like this:
public class OfficeCodeBehind
{
private object oMissing = System.Reflection.Missing.Value;
private Office.CommandBar CBar;
private Office.CommandBarComboBox CBarComboBox;
private Office.CommandBarButton CBarButton;
// ...
}
Next, you will need to write some code to create the different user interface
elements that you plan to place on the command bar. In this example, you
will need a combo listbox and a button. (You may need to change the connec-
tion string, highlighted in bold, to suit your SQL Server or MSDE installation.)
Figure 11-2. Microsoft Office Project Wizard
370
|
Chapter 11, Visual Studio Tools for Office
#84 Create a Command Bar in Word 2003
HACK
You will notice that in this section of code, you will be using
the
oMissing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Microsoft Visual Studio 2015 Unleashed, Third Edition

Microsoft Visual Studio 2015 Unleashed, Third Edition

Mike Snell, Lars Powers
.Net Framework Essentials

.Net Framework Essentials

Thuan L. Thai, Hoang Lam
C# 5.0 Unleashed

C# 5.0 Unleashed

Bart De Smet
Programming .NET Security

Programming .NET Security

Adam Freeman, Allen Jones

Publisher Resources

ISBN: 0596008473Errata Page