Microsoft Office 97 Programming with VBA for Dummies

Overview

Add programs that you've written in Visual Basic for Applications (VBA) to the new and powerful Office 97 suite of word processing, spreadsheet, database, communications, and scheduling software, and you end up with customized solutions that increase productivity, improve accuracy, and enhance creativity. Microsoft Office 97 Programming with VBA For Dummies shows you how. In this practical, easy-to-understand reference, authors and computing gurus Karen Jaskolka and Mike Gilbert quickly introduce you to VBA and ...
See more details below
Available through our Marketplace sellers.
Other sellers (Paperback)
  • All (8) from $1.99   
  • Used (8) from $1.99   
Close
Sort by
Page 1 of 1
Showing All
Note: Marketplace items are not eligible for any BN.com coupons and promotions
$1.99
Seller since 2014

Feedback rating:

(53)

Condition:

New — never opened or used in original packaging.

Like New — packaging may have been opened. A "Like New" item is suitable to give as a gift.

Very Good — may have minor signs of wear on packaging but item works perfectly and has no damage.

Good — item is in good condition but packaging may have signs of shelf wear/aging or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Acceptable — item is in working order but may show signs of wear such as scratches or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Used — An item that has been opened and may show signs of wear. All specific defects should be noted in the Comments section associated with each item.

Refurbished — A used item that has been renewed or updated and verified to be in proper working condition. Not necessarily completed by the original manufacturer.

Good
3.5" disk included. Some wear to the cover, A copy that has been used, but remains in clean condition. All pages are intact, and the cover is, this may or may not include ... dustcover. The spine may show signs of wear. Pages can include limited notes and highlighting, and the copy can include "From th Read more Show Less

Ships from: Pasco, WA

Usually ships in 1-2 business days

  • International
  • Standard, 48 States
$1.99
Seller since 2006

Feedback rating:

(59893)

Condition: Good
Shows some signs of wear, and may have some markings on the inside. 100% Money Back Guarantee. Shipped to over one million happy customers. Your purchase benefits world literacy!

Ships from: Mishawaka, IN

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$1.99
Seller since 2014

Feedback rating:

(1748)

Condition: Acceptable
Reading copy. May have notes, underlining or highlighting. Dust jacket may be missing.

Ships from: Hillsboro, OR

Usually ships in 1-2 business days

  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$1.99
Seller since 2007

Feedback rating:

(9849)

Condition: Acceptable
Millions of satisfied customers and climbing. Thriftbooks is the name you can trust, guaranteed. Spend Less. Read More.

Ships from: Auburn, WA

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$3.50
Seller since 2010

Feedback rating:

(17)

Condition: Very Good
1997 Trade paperback Very good. No dust jacket as issued. Trade paperback (US). Glued binding. For Dummies (Computers). Audience: General/trade.

Ships from: rahway, NJ

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$15.99
Seller since 2014

Feedback rating:

(37)

Condition: Good
Buy with Confidence. Excellent Customer Support. We ship from multiple US locations. No CD, DVD or Access Code Included.

Ships from: Fort Mill, SC

Usually ships in 1-2 business days

  • Standard, 48 States
$30.75
Seller since 2014

Feedback rating:

(273)

Condition: Good
Possible retired library copy, some have markings or writing. May or may not include accessories such as CD or access codes.

Ships from: Chatham, NJ

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$99.08
Seller since 2014

Feedback rating:

(273)

Condition: Very Good
Very good.

Ships from: Chatham, NJ

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
Page 1 of 1
Showing All
Close
Sort by
Sending request ...

Overview

Add programs that you've written in Visual Basic for Applications (VBA) to the new and powerful Office 97 suite of word processing, spreadsheet, database, communications, and scheduling software, and you end up with customized solutions that increase productivity, improve accuracy, and enhance creativity. Microsoft Office 97 Programming with VBA For Dummies shows you how. In this practical, easy-to-understand reference, authors and computing gurus Karen Jaskolka and Mike Gilbert quickly introduce you to VBA and then offer specific VBA programs and techniques that you can readily apply to your own projects. Karen and Mike show you how to
  • Avoid reinventing the wheel by using VBA functions that have already been written for you
  • Automate all kinds of Office 97 tasks
  • Explore and use VBA objects
  • Manipulate Excel spreadsheet pivot tables for fancy, intelligent data analysis
  • Fashion custom interfaces
  • Efficiently and consistently produce professional-looking charts
  • Implement powerful search and replace functions
  • Augment the built-in mail merge capabilities of Office 97
  • Create effective, persuasive presentations that integrate word processing, spreadsheet, and database information

Plus, Microsoft Office 97 Programming with VBA For Dummies includes a bonus disk containing source code from the book. Study it, experiment with it, and even adapt it for your own programs.

Read More Show Less

Product Details

  • ISBN-13: 9780764501821
  • Publisher: Wiley, John & Sons, Incorporated
  • Publication date: 7/28/1997
  • Series: For Dummies Series
  • Edition number: 1
  • Pages: 432
  • Product dimensions: 7.42 (w) x 9.27 (h) x 1.18 (d)

Table of Contents

Introduction
Who Are You?
Before You Start
Reasons and Conventions
Ports of Call
It's on the Disk
A Guide to the Icons Used in This Book
Where to Go from Here
Part I: Introducing VBA, the Common Language
Chapter 1: Welcome to Office 97
A Few New and Cool Things in Office 97
The Office 97 Dream Team
What Can You Do with Office 97?
Chapter 2: What's This VBA Thing, Anyway?
What Does VBA Do?
Is VBA a Macro Language?
But Wait, There's More!
Tonight on Biography: VBA, the Common Language
VBA and Its Predecessors
The Architecture of VBA
Where Is VBA Going?
Where Are We Going?
Chapter 3: Where Does All That VBA Code Live?
Introducing the Visual Basic Editor
Overall Project Properties
General tab
Protection tab
VBE Windows
Project Explorer
Project properties
Immediate response with the Immediate window
What about that Toolbar?
Where's the Beef? (Oops, We Mean the Code!)
Open a window! It's code in here!
Code editor options you'll care about!
Now, What about Access?
Getting to the code
De-bug, de-window, de-code (Debug window)
More peculiarities -- coding options and toolbar
Code behind forms and reports
Part II: Discovering the VBA Building Blocks
Chapter 4: It Slices, It Dices, It's an Object!
Discovering Objects
What can objects do?
Current events
Method madness
Properties and plots of land
Getting object properties
Object Gangs (Or, Object Collections)
Chapter 5: Your Friend the Object Browser
What Is the Object Browser All About?
Starting the Object Browser and Sizing up Its Parts
The Excel example
Classes list
Members only
Details pane
Those funny symbols
Search-O-Rama
Other Buttons and Zippers
Chapter 6: Dot. Bang! You're Dead -- Bizarre Syntax Explained
Why Do You Need These Odd Symbols?
Dotting Your Objects
Objects within objects
Objects are properties!
Parentheses, Numbers, and Names
Default Properties and Methods (Or, A Way to Write Less Code!)
Now Comes the Big Bang
A Comment from the Peanut Gallery
Chapter 7: Analyzing Excel Objects
Introducing the Excel Object Model
The Application Object Example
Workbooks and Worksheets
Singular or plural -- which is it?
Referring to collection members
Active workbooks and worksheets
Home, Home on the Range
Explicit range addresses
Name that range
Range object versus Range property
Cells property
Offset property
Chapter 8: A Word about Word Objects
An Object Model Explosion
The Mother of All Word Objects
Working with Document Objects and Their Children
Using a range
Working with tables
Checking out templates
Chapter 9: Presenting PowerPoint Objects
It's the Same Object Model, Only Different
Working with Presentations
Applying a design template
Saving presentations
Juggling presentations, new and old
Slip Sliding Away
What flavor would you like?
Please go to the end of the presentation
Whipping Shapes into Your Slides
Getting in shape for free
Frames, ranges, text . . . you've got to be kidding!
Stupid text tricks
You put your indent in, you put your indent out . . .
Show Me the Slides!
Chapter 10: Accessing Access Objects
Do Command Dot What?
How DoCmd works
A more complex DoCmd example
Opening Forms with DoCmd
Start with something simple
Form filtration
Filters on the fly
The Form's the Thing
More forms than the government
Some simple form tricks
Controlling Controls
Getting values
Those sneaky list boxes
Setting values
Part III: Everything Else You Need to Understand about VBA
Chapter 11: A Variable's Life
All You Need Is Love and Variables
Selecting a Storage Container
Conceiving a Variable
Using Your Variables
Variable Scoping
To Declare or Not to Declare, That Is the Question
Implicit declaration
Option Explicit
A Different Kind of Variable -- Object Variables
Using an object variable
House cleaning
Constants -- No Variables Needed
Chapter 12: Conditioning Your Code
If..Then . . . What?
Using If..Then statements
Using If..Then..End If
Using If..Then..ElseIf..End If
If..Then statements leaving the nest
An Immediate If
Case Statements
When Case is better
Using Case
Deciding on a Conditioner (Making the CaseĀ­If..Then Decision)
Chapter 13: Loop-de-Loop
How Not to Loop
Do You Think We're Loopy?
While you're at it, keep looping
Do this until you drop loop
Exit the Do loops
For My Next Trick
Get me outta here
Kick 'em out of the nest
With..End With
Do Something for Each of These Do-Hickeys
While..Wend
Chapter 14: Subs and Functions and Arguments, Oh My!
A Crate for Your Code
Why Use Procedures?
When to Use a Sub
Creating a Procedure
Point and click procedures
Going it alone
Event-urous procedures
The Anatomy of a Procedure
The Declaration of Subs and Functions
Don't Just Stand There -- Do Something!
We all live in a mellow subroutine
This functional family
Making Procedures Go
Your friend the Immediate window
Subroutines are macros!
I'll call you
The return of the event procedure
When Arguments Are Useful
Start at the top
Arguing with a subroutine
Calling argumentative procedures
Chapter 15: Using VBA Built-in Functions
Before We Go Any Further
Keeping the User Involved
Putting Messages in a Box
Button it up
InputBox -- when you need more
Number Crunching
What's your sign?
Spin the wheel of VBA
It's a String Thing
Up and down and up and down and . . .
Leaner strings in only one line!
Left? Right? Make up your mind!
Little string, where are you?
How to Get a Date
I want it now!
Present, past, and future
Dialing Information
Name that data!
Data type alchemy
Chapter 16: Creating User Forms
Getting Started with User Forms
Adding a user form
Sizing the form
Setting form properties
Adding Control to Forms
Practice makes perfect
Setting control properties
Making Forms Say "Hi, There!"
Show me the form
Adding some intelligence
Reading and Writing Form Data
Initializing the controls
A quick test
Reading data back
The Grand Finale
Chapter 17: Planning for Trouble and Knowing How to Handle It
Getting the Bugs Out
Avoiding bugs
Opening the debugging toolbox
Visual Basic Editor debugging tools
Access 97 debugging tools
Error Handling Unleashed
On error do this
Resume code execution
Elvis has left the building
Doing it up right with error handling
Part IV: Doing Cool Stuff with VBA and Office
Chapter 18: Programming Excel Pivot Tables
The Nature of the Beast
Why pivot?
Pivot table wizardry
Tables, fields, and items
Getting the answers that you want
Customizing Pivot Tables with VBA
Filling the lists
Moving fields around
Copying the results
Give It a Try
Chapter 19: Charting Excel Data
What's in a Chart, Anyway?
Where Are the Charts?
ChartWizard -- One-Step Charts
A Few Cool Chart Tricks
Organizing a Union
Adding a new series
Properties for sale
Point me at the data
Chapter 20: Hard-Core Find and Replace in Word
The Challenge
Planning the Attack
Up, Up, and Away with VBA to Save the Day
Creating somewhere to write our code
Setting up constants
Opening our documents
Search and replace
Setting the range
Finishing touches
Did You Forget Error Handling?
Ready, Set, Go!
Chapter 21: Making Mail Merge Work for You
Mapping Out Our Course
Setting the Stage
Creating a User Form
Getting out the Tinker Toys
Time to write the code to make your form go!
So far, so good
Writing Some Module Code
Try It Out
Finishing Touches
Chapter 22: Making PowerPoint Presentations Come Alive
Constructing Presentations by Using VBA
Importing text-file data
Dressing it up
Laying out your slides
Setting slide show options
Welcome to the Big Show
Building Dynamic Presentations
Our sample presentation
Setting up hyperlink jumps
Adding navigation buttons
Responding to mouse movement
Chapter 23: Automating Access Reports
What's the Point?
Don't Write Code; Use a Table!
Choose All You Want
Who Selected What?
Cranking Out Reports
Adding Error Handling
Letting the User Cancel
Juggling the Buttons
Dressing Up the User Interface
The Whole Deal
Part V: The Part of Tens
Chapter 24: Ten Tips for Migrating Your Applications to Office 97
Where did my code go?
Strong typing (You mean I have to hit the keys harder?)
16-bit stuff no longer works!
API Unpleasantness
WordBasic is dead, and other gotchas
PowerPoint changes for your own good, even though they ouch!
I asked for a worksheet, not a workbook
You can't go back, and other access tips
Check out the Microsoft Web site
Chapter 25: Ten Sources of Cool and/or Free Stuff for Office 97 and VBA
New Assistants
Go Beyond Help at Microsoft
VBA Companion free eval
Word 97 sample code
ODE AutoDemo
Free issue of Access/Office/VBA Advisor
Free issue of Microsoft Office Developer's Journal
Get informed with Informant
Start your day right
And much, much more . . .
Appendix: About the Office 97 Developer Edition
What is the ODE?
What you get with the ODE
Access developers really like the ODE
Setting up the ODE tools
Distributing Access applications royalty-free
Creating great user interfaces with ActiveX controls
Getting answers with MSDN Sampler
Index
End-User License Agreement
Installation Instructions
IDG Books Worldwide Registration Card
Read More Show Less

First Chapter

Chapter 22

Making PowerPoint Presentations Come Alive

In This Chapter

  • Creating a presentation from a text file
  • Adding slide show effects by using VBA
  • Building dynamic presentations that respond to your users' wishes

It took a long time, but PowerPoint now has its own development environment -- thanks, of course, to VBA. Because Office 97 is still so new, little real world evidence can explain what people are doing with PowerPoint and VBA. Overall, however, VBA is good for two things. First, you can use VBA to help you build your presentation. This means that you can write code to construct and edit slides as well as set slide show properties. Second, you can use VBA to create dynamic presentations. No longer are you limited to a strict linear path. You can use VBA to branch to different parts of a presentation. In this chapter, we explore several ways that you can use VBA to accomplish these goals.

Constructing Presentations by Using VBA

In Chapter 9, we explain the basics of the PowerPoint object model, including how to create slides one at a time by using VBA. If you want to add a slide to an existing presentation, we suggest that you take a detour and read Chapter 9. Another, more efficient way to create slides, especially if you have the information stored somewhere else (such as in a database or word processing document), is to import slides from a text file. The key is to format the text file to make it look like an outline. In this section, we show you how to take a text file and create a glitzy slide show using less than 30 lines of code.

Figure 22-1 shows a text file that we've provided on the sample diskette (it's called Widgets.txt). Tab characters at the beginning of a line create the indentations that you see in this figure. This is how you create an outline that PowerPoint can understand. Lines with no indentation are treated as titles while the others comprise the body of a slide.

Importing text-file data

What we show you here is so easy that we have to create just a single subroutine and add VBA code as we go along. First, create a new procedure in a new presentation:

Each series of steps in the section "Constructing Presentations by Using VBA" builds on the results of the steps that precede it. To create the slide show from a text file, be sure to follow all the steps in this section.

  1. Launch Microsoft PowerPoint.

    PowerPoint displays its opening dialog box, as shown in Figure 22-2.

  2. Select the Blank Presentation option and Click OK.

    PowerPoint displays the New Slide dialog box.

  3. Select the blank slide option in the lower-right corner and click OK.

    PowerPoint displays a new, blank slide.

  4. Press Alt+F11.

    PowerPoint displays the VBA editor.

  5. Choose the Insert-->Module command.

    VBA adds a new module to your project and displays its code window.

  6. Add the following procedure to the code window:

    Sub CreatePresentation()

    Dim strTextFile As String
    Dim objPres As Presentation
    Dim intLastSlide As Integer
    Dim strTemplate As String
    Dim objSlide As Slide
    strTextFile = "C:\DUMMIES\WIDGETS.TXT"
    Set objPres = Presentations.Add
    objPres.Slides.InsertFromFile strTextFile, 0
    End Sub
    • Edit the path in the strTextFile variable to reflect the path to the sample Widgets.txt file on your computer. (This step is necessary only if you used a path other than C:\Dummies when you loaded the sample files onto your computer.)

Don't worry about the extra variables in the procedure. You use them later on in the section titled "Setting slide show options." The last two lines of code in the procedure are the ones that do most of the work. The second-to-last line creates a new presentation by calling the Add method of the Presentations collection. The very last line inserts the contents of the file as an outline.

The zero at the end of the last line of code tells PowerPoint where to put the new slides. Because this is a new presentation, you have to specify zero because there are no existing slides. However, you can use the InsertFromFile method to insert slides at any point in an existing presentation.

To test the procedure as it stands, follow these steps:

  1. Switch back to PowerPoint.
  2. Choose the Tools-->Macro-->Macros command.

    PowerPoint displays the Macros dialog box. You see your new procedure, CreatePresentation in the list. If you don't, open the Macro in the drop-down list and select All open presentations.

  3. Select the CreatePresentation macro from the list and click the Run button.

    PowerPoint runs the procedure. It creates a new presentation and inserts the data from the text file. Figure 22-3 shows the finished product. Granted, it's not very pretty yet. You do that in the section "Dressing it up" later in this chapter.

Go ahead and close the newly created presentation when you're done looking at it.

Dressing it up

Each series of steps in the section "Constructing Presentations by Using VBA" builds on the results of the steps that precede it. To create the slide show from a text file, be sure to follow all the steps in this section.

After you create the slides, you can start to dress up your presentation. Apply a design template first:

  1. Switch to the VBA editor (or press Alt+F11).
  2. Insert the following lines at the bottom of the CreatePresentation subroutine, just before the words End Sub:

    strTemplate = "C:\Program Files\Microsoft " & _

    "Office\Templates\Presentation Designs\" & _
    "Notebook.pot"
    objPres.ApplyTemplate strTemplate

    This code applies the Notebook presentation theme to the newly created presentation.

    • Edit the path to Notebook.pot to reflect the file's location on your hard disk. (This step is necessary only if you changed the default path when you loaded Office 97 onto your computer.)

      You can also pick a different template if you don't like how Notebook.pot looks.

Of course, you can modify the properties of the presentation, one at a time, by using VBA code. But unless you're the type of person who likes to count the grains of sand at the beach, this is not the best approach. It's much better to use one of the design templates that ship with PowerPoint, because they were created by professional designers. You can even create your own!

Laying out your slides

When you import slides from a text file, PowerPoint -- knowing no better -- creates them using the Title and Text layout style. That is, PowerPoint treats lines with no indentation as the title of each slide and all other lines as the body of the slide. Chances are, however, that you want to specify different layouts for some slides in the presentation. In our example, we want to make the first slide the title slide for the presentation (the slide that tells people what the presentation is all about). We also want to remove the text from the last slide, leaving just the title. Fortunately, this is easy. You just set each slide's Layout property.

To add the code to do this, follow the next series of steps.

Each series of steps in the section "Constructing Presentations by Using VBA" builds on the results of the steps that precede it. To create the slide show from a text file, be sure to follow all the steps in this section.

  1. Move your cursor to the bottom of the CreatePresentation procedure if it's not already there.
  2. Enter the following VBA code:

    objPres.Slides(1).Layout = ppLayoutTitle
    intLastSlide = objPres.Slides.Count
    objPres.Slides(intLastSlide).Layout = _

    ppLayoutTitleOnly

The first line in the code fragment looks fairly straightforward. It sets the Layout property of the first slide (slide 1) to the constant ppLayoutTitle. This coding creates a title slide.

To set the layout of the last slide, you can type an exact slide number, but what if the number of slides change? Our code handles this nicely. The second line of code, in the preceding fragment, computes the last slide's number by simply looking at the total number of slides (given by the Count property of the Slides collection). The procedure then uses this number to specify the last slide, setting its Layout property to ppLayoutTitleOnly.

PowerPoint defines constants for each distinct layout style. You can find a list of them in the Object Browser. Just find the entry for ppSlideLayout in the Classes list.

Setting slide show options

Now, you can have some fun with the presentation! Many people (read as bosses) are impressed when you add slick effects to your slide presentations. As you know, anything that you can do through the user interface, you can also do by using VBA. Follow the next set of steps to add some transition effects to the slides in your presentation:

Each series of steps in the section "Constructing Presentations by Using VBA" builds on the results of the steps that precede it. To create the slide show from a text file, be sure to follow all the steps in this section.

  1. Move your cursor to the bottom of the CreatePresentation procedure if it's not already there.
  2. Enter the following VBA code:

    For Each objSlide In objPres.Slides

    With objSlide.SlideShowTransition
    .EntryEffect = ppEffectFade
    .AdvanceOnTime = True
    .AdvanceTime = 5
    End With
    Next

This code sets up a For Each loop that loops through each slide in the newly created presentation. It then uses a With statement to set various properties of each slide's SlideShowTransition object.

For Each loops and the With statement are covered in Chapter 13.

EntryEffect defines the slide show effect used to introduce the slide. The procedure sets this to ppEffectFade, which produces a gradual fading in and out of each slide. (It's very soothing to watch!)

Like the layout options, PowerPoint defines constants for every slide transition. Look for the ppEntryEffect object in the Object Browser Classes list.

If you want the slide show to advance automatically, you must set two additional properties, AdvanceOnTime and AdvanceTime. Setting AdvanceOnTime to True tells PowerPoint, "Yes. Advance this slide automatically." You then set AdvanceTime to the number of seconds (five in this case) that you want each slide to be displayed.

Welcome to the Big Show

It's now time to fire off the slide show. To do that, you need to write just a little more VBA code. Follow this next set of steps to finish the procedure.

Each series of steps in the section "Constructing Presentations by Using VBA" builds on the results of the steps that precede it. To create the slide show from a text file, be sure to follow all the steps in this section.

  1. Move your cursor to the bottom of the CreatePresentation procedure if it's not already there.
  2. Enter the following VBA code:

    With objPres.SlideShowSettings

    .AdvanceMode = ppSlideShowUseSlideTimings
    .LoopUntilStopped = True
    .Run
    End With

The code in the preceding section, "Setting slide show options," modifies the slide show settings for each slide. Slide show settings that are for the presentation itself are stored in, appropriately, the SlideShowSettings object. This code fragment sets the AdvanceMode property to ppSlideShowUseSlideTimings, which tells PowerPoint to advance each slide by using the timing information that you set up. The procedure also sets the LoopUntilStopped property to True. As you can probably guess, this line tells PowerPoint to continue running your masterpiece until you yell "Uncle!" -- er, that is, until you press Esc.

Finally, the procedure calls the Run method. This is what actually kicks off the slide show. You can test the complete procedure by following these steps:

  1. Press Ctrl+S and enter a file name to save the presentation that contains the VBA code you've been working in this section.
  2. Switch to PowerPoint by pressing Alt+Tab.
  3. Choose the Tools-->Macro-->Macros command.

    PowerPoint displays the Macros dialog box. If you don't see the CreatePresentation procedure, open the Macro in drop-down list and select All open presentations.

  4. Select the CreatePresentation macro from the list and click the Run button.

    PowerPoint runs the procedure. After a small delay, the finished slide show starts to run. Figure 22-4 shows the opening screen. Note how the layout is different from the slide in Figure 22-3. The appearance of the slide changes when you make it a title slide.

Building Dynamic Presentations

Not everyone can be a dynamic presenter, so maybe dynamic presentations are the next best thing. By dynamic we mean a presentation that can take different paths, depending on the interests of the person presenting or viewing it. Prior to Office 97, creating dynamic presentations was difficult if not impossible. Now, as you can see in this section, it's easy.

Our sample presentation

To demonstrate the possibilities of dynamic presentations, we've created a very simple presentation and included it on the sample diskette. The filename is Widgets.ppt and the sample contains information on a fictitious company. Figure 22-5 shows the first slide of the presentation in slide show view. The viewer can take three different paths: Clicking on the text near the bottom of the slide takes the viewer to further information on either the company itself, its products, or its contact information.

Although we've taken the time to create the presentation, you need to add the VBA code that is necessary to make the presentation dynamic.

Setting up hyperlink jumps

The first task you need to perform to make the presentation dynamic is to establish the jumps to other slides in the presentation. These jumps let the viewer go directly to the information he or she wants to see. Normally, we have you open the code window and start to type but, believe it or not, you don't need any code to make this jumping process work!

Every object you place on a slide can have a custom action associated with it. Specifically, whenever you move the mouse over an object or you click an object, you can tell PowerPoint to do something. If you want, you can tell PowerPoint to run some VBA code. In fact, we show you how to do this in the section "Responding to mouse movement" in this chapter. But you can also jump to another slide by using a new feature of PowerPoint 97, hyperlinks.

If you've ever surfed the Web you may be familiar with the concept of hyperlinks. Hyperlinks are simply destinations that are associated with an object (like a picture) or some text on a Web page. The same concept applies to PowerPoint 97. You can associate a destination with each object on a slide, that destination being another slide in the same presentation! Of course, you can also set up hyperlinks to your favorite Internet site as well.

Each series of steps in the section "Building Dynamic Presentations" is founded on the results of the steps that precede it. To create a dynamic, interactive presentation by using VBA, be sure to follow all the steps in this section.

To set up links from the first slide to other slides in the presentation, follow these steps:

  1. Open the sample presentation for this section, Widgets.ppt.

    PowerPoint displays the first slide in the presentation. If for some reason you don't see the first slide, press the Home key.

  2. Select the text box that contains the words Company Information.

    PowerPoint draws a gray border around the text, as shown in Figure 22-6. It's important that the text box, and not the text inside it, is selected. If you see a blinking cursor, then you've selected the text. Click once on the gray border to select the text box.

  3. Choose Slide Show-->Action Settings.

    PowerPoint displays the Action Settings dialog box for the text box, as shown in Figure 22-7. Using this dialog box, you can dictate what happens when a user clicks an object with the mouse.

  4. Select the Hyperlink to option button.

    PowerPoint enables the drop-down list next to the option button.

  5. Open the Hyperlink to drop-down list and select Slide.

    PowerPoint displays the Hyperlink to Slide dialog box, as shown in Figure 22-8. This box lists each slide in the active presentation and shows a thumbnail version of the selected slide.

  6. Select the Company Information slide from the list and click OK.

    PowerPoint closes the Hyperlink to Slide dialog box and returns you to the Action Settings dialog box. Company Information now shows in the drop-down list.

  7. Click OK to close the Action Settings dialog box.
  8. Repeat Steps 2 through 7 for the two other text boxes, Product Information and Contact Information, to create hyperlinks to the Product Information and Contact Information slides, respectively.

Assuming that you got all the hyperlinks set up properly, you can now jump to any slide in the presentation directly from the front page. To test this, follow these steps:

  1. Choose View-->Slide Show to open the presentation in a slide show window.

    PowerPoint opens the presentation in a full screen slide show.

  2. Click the text Contact Information with the mouse.

    PowerPoint displays the Contact Information slide, which is actually the fourth slide in the presentation.

  3. Press the Home key to return to the first slide.
  4. Click the text Product Information with the mouse.

    PowerPoint displays the Product Information slide.

  5. Press the Esc key to end the slide show.

If PowerPoint doesn't jump to the right slide or nothing happens at all when you click the mouse on the hyperlinks, reopen the Action Settings dialog box for the misbehaving text box and make sure that the settings are correct.

Adding navigation buttons

Jumping to a particular slide is nice, but what if you want to get back to the first screen or just browse through each screen? If you need this type of functionality you can augment the hyperlinks that you create with a set of navigation buttons on each slide. The advantage to having buttons on each slide is that the person viewing the presentation always has a consistent set of controls at his or her fingertips.

In this section, we show you how to add buttons to go to the next slide, the previous slide, and back to the first slide. Just follow the next set of steps.

Each series of steps in the section "Building Dynamic Presentations" is founded on the results of the steps that precede it. To create a dynamic, interactive presentation by using VBA, be sure to follow all the steps in this section.

  1. Make sure that the presentation sample is open in PowerPoint.
  2. Choose View-->Master-->Slide Master.

    PowerPoint displays the slide master screen, as shown in Figure 22-9. Any objects that you place on the slide master are visible on every slide in the presentation.

  3. If the Drawing toolbar is not already visible, choose the View-->Toolbars-->Drawing command to display it.

    Refer to Figure 22-9 to see the Drawing toolbar along the bottom of the screen.

  4. Click the AutoShapes button on the Drawing toolbar.

    PowerPoint displays a list of AutoShape categories.

  5. Click the Action Buttons command.

    PowerPoint displays the Action Buttons tool palette, as shown in Figure 22-10. All of the controls on this palette are designed to respond in one way or another to mouse clicks.

  6. Click the Home action button.

    It's the one that looks like a little house with a chimney. Your mouse cursor changes to crosshairs which indicates that you can now draw the object on the slide.

  7. Click and drag the mouse onto the surface of the slide master to draw a small back button.

    Figure 22-11 shows what you want the button to look like. Make it large enough to be clicked easily but small enough so that it's not obtrusive. As soon as you draw the button, PowerPoint opens the Action Settings dialog box. PowerPoint has already selected a Hyperlink to the first slide in the presentation.

  8. Click the OK button to close the Action Settings dialog box.
  9. Repeat Steps 4 through 8 to create Next and Previous action buttons next to the Home button.
  10. Choose View-->Slide to close the slide master when you're done.

As you can see from the example, the built-in action buttons can save you time if you want to hyperlink to other slides in the presentation. They don't give you the design flexibility of other objects, however.

If you click and drag on the dark line at the top of the palette, you can tear off Office 97 tool palettes. When you tear off a palette, it stays displayed on the screen instead of disappearing. This makes it easy to select multiple tools from the same palette because you don't have to constantly reopen the Auto Shapes list.

Now that you've created the buttons, choose the View-->Slide Show command and run the slide show to test the buttons. Notice that the buttons don't appear on the first slide. That's because PowerPoint maintains a separate master for the title slide. Move to one of the other pages, however, and you see the buttons. Click them to move through the presentation.

Responding to mouse movement

We mention that you can also run code instead of using simple hyperlinks, and we know that you've been champing at the bit to write some. In this section, we show you how to call a simple procedure when you move the mouse over a slide's text boxes.

Each series of steps in the section "Building Dynamic Presentations" is founded on the results of the steps that precede it. To create a dynamic, interactive presentation by using VBA, be sure to follow all the steps in this section.

To begin, write the procedures that you want to call. Follow the steps listed below to create some VBA procedures inside the slide presentation:

  1. With the presentation still open, press Alt+F11 to open the VBA editor.
  2. From the Projects window, under the Widgets.ppt project, select Slide1.

    VBA highlights Slide1, the VBA component that corresponds to the presentation.

  3. Press F7.

    VBA opens the code window for the presentation.

  4. Create a new procedure in the code window by typing the following VBA code:

    Sub MoveArrow(intShapeNumber As Integer)

    Dim shpShape As Shape
    Set shpShape = ActivePresentation.Slides(1). _
    Shapes(intShapeNumber)
    With SlideShowWindows(1).View.Slide. _
    Shapes("AutoShape 13")
    .Top = shpShape.Top
    .Left = shpShape.Left - .Width
    End With
    End Sub

    This creates a procedure that accepts the number of a shape on the title slide as an argument. It then positions the arrow shape just to the left of it.

    • Now create three new subroutines by typing the following VBA code after the End Sub line of the procedure that you just created:

      Sub MoveArrowCompany()

      Call MoveArrow(6)
      End Sub

      Sub MoveArrowContact()

      Call MoveArrow(8)
      End Sub

      Sub MoveArrowProduct()

      Call MoveArrow(7)
      End Sub

      These procedures call the first procedure, passing the shape number of one of the three text boxes. You must create these procedures because you can't call procedures that accept arguments from a PowerPoint shape. The code window now looks like the one shown in Figure 22-12.

Now that the code is written all you need to do is hook it up to the text boxes on the slide. To do this, you use the Action Settings dialog box, just as you do for hyperlinks:

  1. Switch back to PowerPoint from the VBA editor.
  2. Select the Company Information text box on the title slide.

    PowerPoint draws a gray rectangle around the text box to show you that the text box is selected.

  3. From the Slide Show menu, select the Action Settings command.

    PowerPoint displays the Action Settings dialog box for the text box.

  4. Click the Mouse Over tab on the Action Settings dialog box.

    PowerPoint shows you an identical dialog box, except that the action you define here takes place when you move the mouse over the object.

  5. Click the Run macro option button.

    PowerPoint enables the macro list just below the option button.

  6. Open the drop-down list and select Slide1.MoveArrowCompany from the list.
  7. Click OK to close the Action Settings dialog box.
  8. Repeat Steps 2 through 7 for the two other text boxes, Product Information and Contact Information, selecting the Slide1.MoveArrowProduct and Slide1.MoveArrowContact procedures, respectively.

Start the slide show and move the mouse over the text boxes to test the procedures. Of course, the procedures are fairly trivial, but you can use the same technique to run sophisticated procedures, as well.

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)