[ABC home]    [ABC Archives by Issue]   [ABC Archives by Author]  [Search]  [Privacy]

 

ABC logo
ABC Home

 

Advertise in ABC

 

Learn more
about
Dian Chapman
Dian Chapman

Read
Dian's Archives
Read Dian's Archives

Online classes
at Eclectic Academy
 Instructor led online courses at Eclectic Academy

PowerPoint to Exe
convert PowerPoint presentations to exes

Lock 'n Hide
Folder Security

Hide files and folders in Windows 9X

 

ABC ~ All 'Bout Computers
The Online Web-azine for Computer Enthusiasts
-- brought to you by
Visit Linda's Computer Stop

contents page for this issue

Trigger Your Word Docs
~~Dian Chapman, Technical Consultant, MouseTrax.com

Have you ever wished that you could put a trigger into a document or report that would help users by causing some type of event to happen? Think about it. You have a report template that you need users to complete. But some of the information in the document is a bit obscure. You’d like to add a little extra information to explain what is required, but you don’t want to have the report appear too complex due to a lot of additional explanation text. Text that more advanced users might find annoying. How can you cover both bases—keep the document clean for the advanced users, but provide that extra assistance for new users?

By adding a little VBA code, you can slip in little triggers to provide the new users with ways to get the additional help they need.

MacroButton Triggers

I recently created a template for users who were somewhat unfamiliar with the task of writing a project scope. Most of them needed additional explanations to understand what information had to be entered into each portion of the document. I first use the standard method of adding help dialog boxes along a menu. However, not all the users paid attention to the menus. I realized I needed a more direct way to provide them with information. So I tried another trick, which has worked out well for them.

I added in all the section titles that were needed. Then I converted the title text into MacroButtons. A macrobutton is text or an image that, when double clicked, will trigger a macro. Note, however, that additional code can also be added that will convert the default double click for MacroButtons to single click activation.

As you can see in the final result below, if the user clicks on a section title, a dialog box now appears that provides additional details.

Scope Help message

Showing the users that they just need to click any title for more information turned out to be a much easier way for them to work.

To create a macrobutton, you first need to write some type of actual macro. In this case, I created a dialog box to display. But I could have just used a message box.

create a dialog box

A display macro was created for each dialog box that simply tells the dialog box to show itself.

frm_06ConceptDefinitions.Show

And a hide command was placed under the OK button, to cause the dialog box to go away and remove it from memory when the user dismissed the message.

frm_06ConceptDefinitions.Hide
Unload frm_06ConceptDefinitions

Once the macros were created, I added the MacroButton field code to the document to trigger the macro to run, and thereby cause the help dialog box to be displayed. You can build the MacroButton field manually by hitting Ctrl + F9 to insert the Word field brackets. Then construct the needed code using the following syntax:

code syntax

Or you can click Insert > Field > MacroButton and fill in the needed information through the Word user interface.

If you need more help understanding how to use a MacroButton field, check Word’s Help or see this TechTrax article, which explains how to add an envelope icon to a page to trigger an envelope to print: Instant Envelopes Using the MACROBUTTON Field and VBA.

ActiveX Command Control

Another method I’ve used before is to add an ActiveX Control command button to a document. This works in much the same way as the MacroButton, except that it puts an actual command button on the page.

Automated forms can be programmed to start running immediately when the user accesses the file. However, in some cases, this isn’t always the best way to develop a form. Once I had to create a license request form. But some users wanted to just check the cost of a license before they went whining to their boss to beg for a software purchase. So I added command buttons to the form to allow the users to decide how they needed to use the form. If they just wanted to check a price, they would click that button. However, if they already had approval to submit the request form, they could go ahead and click the other button to start the form fill-in activation, as you can see in the image below.

sample form with button

The only problem with using ActiveX Controls is that, if you get carried away and use too many, it will add a lot of excess weight to your document. Weight that could cause the document to open slowly or even crash! Use them sparingly. If you only need two or three triggers, you can get away with using command buttons. But if you need several triggers, a MacroButton is much less weight on your document.

To access the Control Toolbox that contains the ActiveX Controls, click View > Toolbars and select the Control Toolbox.

select Control Toolbox

These controls look very similar to the ones you’ll find on the Forms toolbar. However, Form Fields can be used without the need of VBA programming code. ActiveX Controls need code to activate them. Also, as I mentioned, they add a lot more weight to your document.

Command Button

Click the Command Button control from the Control Toolbox to add a button to your document. Once added, right click to access the Properties dialog for the control. This is where you configure the command button to look and behave the way you want. As you can see, I’ve added the Caption "Help," as well as adjusting the font size for the button text display.

Command button properties

By making the font smaller, I can now click and drag a corner of the button so it doesn’t take up too much space on the document.

resized button

Code needs to be added to the control to cause something to happen when the user clicks the button. In this case, I’ll simply add a message box that will be displayed when the user clicks the command. If I’d created a dialog box and wanted that to display, this is where I would add my .show command to cause the dialog box to be displayed.

message box text

Now when the user clicks on the Help button in the document, my message is displayed, as you can see below.

message box

Removing Controls

Another problem with adding command buttons to your document is that the button will also print when the document is printed. If this is an issue for you, then you will need to add a way to have all the command buttons removed from the document prior to printing.

I’ve seen some elaborate code procedures that can be used to remove controls. And a Microsoft article explains that you can turn off the Drawing Object printing option from the Tools > Options > Print dialog box. But what if you have other drawings in the document that need to be printed?

A simple solution is to just wrap the control with a bookmark! Select the command button and hit Alt + I + K to add a bookmark around the control.

Make it a bookmark

Now you can write a simple procedure that changes the content of the bookmark to nothing…thereby removing the control from the page prior to printing. The code below would set a bookmark called "bkButton01" to nothing by entering two double quotes with no information between them.

ActiveDocument.Bookmarks("bkButton01").Range.Text = ""

code to remove bookmark

Of course, now you’ll have to trigger this procedure to run at some point. You can capture the print command and add code to set all the control bookmarks on your page to nothing. Or you can add another command button that also does the trick. Just remember that you’ll be adding even more weight to your document if you choose to add yet another command button.

button to remove buttons

If your users understand how to pay attention to custom menus, you can add a command to your menu bar for this document that triggers the code to remove the buttons, as shown below.

toolbar button

When the users click this menu option, the procedure to set all the bookmarks to nothing will run, thus removing the buttons, automatically.

If you need further help learning how to customize Toolbars, see this MouseTrax article: Customized Toolbars and Menus. If you want more help learning how to create custom dialog boxes, check out this TechTrax article: Creating Custom Dialog Boxes. If you’d like to learn more about automating documents in Word by using VBA, be sure to check out my Word AutoForms & Beginning VBA eBook or Video course at this link: http://www.mousetrax.com/techcourses.html. And if you’d prefer to have an expert show you all the ways you can save time and money by using automated documents in your business, see my consulting page at: www.mousetrax.com/consulting .

Dian Chapman is a Technical Consultant, Microsoft MVP, Instructor of several advanced Word online courses, Editor of TechTrax, free support Ezine (http://www.mousetrax.com/techtrax/), and author of the eBook: Word AutoForms and Beginning VBA.

Dian specializes in AutoForms creating and training, technical writing, web development and tech support. She enjoys teaching people how to enjoy their computers more and loves the challenge of providing automated solutions to business problems. You can find out more about Dian and read many more of her tutorials by visiting her web site at http://www.mousetrax.com/ and her online magazine at http://www.mousetrax.com/techtrax/ And if you’re interested in learning more about creating Word AutoForms or you’d like to start learning how to use Visual Basic for Applications, Word’s programming language, be sure to check out her new eBook at http://www.mousetrax.com/books.html and her online classes at http://www.mousetrax.com/techclasses.html.

My Newest Book
Excel 2003 Study Guide

published by Wiley
get it at Amazon,
at Barnes & Noble,
or at Borders

 


 Support ABC

Linda's Ebooks
Ebooks on Access, Excel, Outlook, PowerPoint, Publisher, and Word

Linda's CD
Order Linda's CD and learn all of the Office programs

The Newbie Club
Learn all about computers the easy way

Online classes
at Eclectic Academy
 Instructor led online courses at Eclectic Academy

FrontLook
Add-ins
& Screen Capture


 

 

 Privacy Policy, Disclaimer, and Legal Stuff
This page was last updated on Monday, December 31, 2007 . copyright © 2000 - 2008, Linda F. Johnson, Linda's Computer Stop, ABC ~ All 'Bout Computers. All rights reserved.
[SEARCH THIS SITE]