RibbonX for Dummies: Chapter 6 (Part 1) (
Page 1 of 4 )
RibbonX For Dummies®
Chapter 6: Developing Business Applications for Word
ISBN: 978-0-470-16994-0
Copyright of Wiley Publishing, Inc.
Indianapolis, Indiana
Posted with Permission
RibbonX For Dummies®
Chapter 6: Developing Business
Applications for Word
ISBN: 978-0-470-16994-0
Copyright of Wiley Publishing, Inc.
Indianapolis, Indiana
Posted with Permission
Chapter 6
Developing Business Applications for Word
In This Chapter
- Understanding how to work with Word
- Designing a letter and memo tab
- Using automation to create envelopes
- Designing labels
- Defining and automating forms
Microsoft Word is the tool of choice for most documentation tasks in organizations of every size. In fact, Word sees use in more than just the corporate world; you’ll see it used in everything from home businesses to college campuses. The kind of documents that people create using Word is also nothing short of amazing. In many cases, developers think about Word as a means of creating a letter or providing documentation to others. However, Word also sees use as a means of filling out forms and even accessing Web services. Some people use Word exclusively to create reports, while others use it to formulate presentations. You could possibly make a career out of finding new uses for Word alone — and that’s not even considering the other elements of the Office suite.
This chapter discusses a number of major application categories for Word that include the typical letter or memo and more unusual uses such as reports. In between, you’ll find applications to create envelopes, design labels, and automate forms. The last application in the chapter even describes how to use Word when working with graphics. Although this chapter hardly exhausts every possible use for Word, you’ll find enough variety here to make it significantly easier to create a Word application of your own for your personal or organizational use. You’ll also find that the chapter divides the examples by language.
The simpler examples (letter and memo, envelopes, and labels) rely on VBA as a language because they lend themselves to that particular environment. Yes, you could easily create these examples using Visual Studio, but these examples don’t really require such an advanced product. Likewise, the chapter uses Visual Studio to create some of the more complex examples (forms, reports, and graphics applications). Even though you could create these examples using VBA, the complexity of doing so outweighs other benefits you receive by using Visual Studio.
Getting Started with Word Applications
Word is one of the most used of the Office applications. The following list tells some of the reasons that Word is so popular:
- Provides a broad range of uses
- Offers a significant amount of flexibility
- Customizes well to a variety of needs
- Lets you produce output in final format
You have a choice of using VBA or Visual Studio when working with Word, but the choice isn’t simply one of personal taste or capabilities. Because of the way that Microsoft has added Ribbon functionality to Word, you might find your choice dictated more by the needs of the application than any other factor.
Understanding Word and VBA
VBA offers the best choice for document- or template-centric tasks. For example, most companies rely on a particular template to create letters. Some companies may have several templates for the purpose. However, it’s unlikely that a company will have employees whose sole purpose is to type letters (and absolutely nothing else), so it’s unlikely that a Ribbon add-in for letters will work very well. Using VBA to produce a template for letter add-ins is a significantly better choice.
Any application that affects only a subset of the documents produced by Word is a candidate for VBA. However, don’t get the idea that VBA is always the best choice. For example, it might appear at first that VBA is the only choice when creating a forms application. The way the user employs the form is the determining factor in this case. If you create a form that the user must fill out for every project, such as a routing sheet, then the form may work better as an add-in, which means you should use Visual Studio instead of VBA to complete the task.
Unfortunately, you can’t combine VBA and Visual Studio with any ease unless you plan carefully. For example, you could create an add-in that provides basic functionality, and then augment that capability based on the document or template using VBA. For example, thinking about the forms example again, you could create general forms capability using a Visual Studio add-in, and then augment that functionality using VBA. Each document or template could include special form features for that particular need.
Understanding Word and Visual Studio
The add-ins you create using Visual Studio affect every document that the user opens with Word. Consequently, Visual Studio is the best tool to use when you want to create an application that affects the user all of the time. If there’s a company policy in place that the user can’t underline anything in a document or use strikethrough without employing revision marks, then you could add that restriction quite easily, using an add-in. The policy would remain in effect no matter which document the user opened.
As mentioned in the “Understanding Word and VBA” section of the chapter, some forms lend themselves to add-ins. You might also want to offer final output options as part of an add-in. For example, a user might always have to create output in a report format no matter what document they work with. The report format could be something as simple as adding the company’s logo to the output or including a special notice. Of course, reports can take other forms and you can make the output as simple or as fancy as needed. The point is that reports often encompass more than one document type and lend themselves to implementation as an add-in as a result.
A more common global application need is graphics. Word comes with a good set of graphics primitives, which works fine if you happen to be an artist. However, for those who don’t draw well, the graphics primitives are probably a little too primitive. A graphics tab could provide access to companyapproved icons and clip art. The tab could even include guidelines for adding the art to a document.
Creating a Letter/Memo Tab
The Letter/Memo tab, shown in Figure 6-1, demonstrates the perfect use of a custom tab to promote workflow. In this case, the user moves from left to right across the Ribbon. When the user reaches the last group, the user has a new, perfectly formatted, letter in place. The major concept, in this case, is to keep the user moving and yet provide complete assistance. The template ensures that the user doesn’t miss anything and that every element appears as it should according to company guidelines. Most important of all, the user doesn’t have to think too hard about anything; the template helps the user create a letter without forcing the user to think about menus, toolbars, special formatting, or anything else of that nature. The tab doesn’t hide anything, either; it doesn’t have to in order to make things easy.
One of the more important issues to consider is whether a particular set of features applies to a document or a template. A user is quite likely to create multiple letters and memos, so this example works best as a template. However, when you create the Ribbon and associated VBA macros, it’s actually easier to work with a document because you can see the results of any changes faster. Consequently, this example began with a document and ended as a template to make development considerably easier.
The Letter/Memo tab example demonstrates several techniques, and the chapter simply can’t hold all the required source code. For example, you won’t see all of the source code for the Ribbon because the book already has several examples of this code. The text also skips repetitive coding examples and presents only one version of a particular coding technique. The sections that follow do provide you with complete information about all of the essential techniques for working with this example and modifying it to meet your specific needs. (You can find the complete source code for this example on the Dummies.com site at http://www.dummies.com/go/ribbonxfd.) This example relies on the Letter and Memo.DOTM template, and the Sample Letter.DOCM document.
Figure 6-1: Use custom tabs to promote a workflow within your organization.