SharePoint Development from a Documentation Perspective

Andrew May

September, 2004

  • Andrew May's WebLog

    PowerPoint: Pause a Sound File During Slide Show

    • 2 Comments

    Here’s one of my rare post concerning things you can do without using code.

    I got an email the other day from a user who had read my blog entries about inserting sound files using code. He had an issue he was looking for help with. He didn’t seem all the comfortable with programming, but was willing to learn some coding if it solved his problem.

    Here’s what he wanted to do: He had recorded narration for a slide as an mp3 file. He knew how to insert the file, and set it to play automatically, but he also wanted to have a Pause/Play button on the slide itself, so he could pause the narration at will during the slide show.

    I knew how I’d set that up in code, but it seemed like a reasonable thing that users would want to be able to do without resorting to automation. So I went to our ever-helpful end-user writers, and sure enough, you can do what he wanted to without writing a single line of code. After they showed me how, I wrote up instructions and mailed them to him. Then I figured I might as well post them on my blog, in case anyone else was trying to do something similar. So here they are.

    When you break it down, here’s what we actually want to do:

    ·        Insert narration that plays automatically when the slide loads.

    ·        Add a button that lets you pause the narration during the slide show.

    So here are the four general tasks we need to set this up:

    1.      Insert the sound file on the slide, and set it to play automatically.

    2.      Add a ‘Pause’ button to the slide.

    3.      Add a custom animation to the slide that pauses the sound file.

    4.      Set the custom animation so that it’s triggered when you click the Pause button.

    First, let’s insert the sound file:

    1.      From the Insert menu, select Movies and Sounds, and then select the option for the sound you want to insert (Sound From File, etc.).

    2.      We want the narration to start when the slide loads, so click Automatically when prompted.

    Next, add the action button:

    1.      From the Slide Show menu, select Action Buttons, and then click the button you want to use.

    2.      Draw the button on your slide.

    3.      When the Action Settings dialog box appears, under Action on Click, select None, and then click OK.

    Next, add a custom animation to your slide:

    1.      From the Slide Show menu, click Custom Animation.

    The Custom Animation pane appears.

    2.      In the Custom Animation pane, select Add Effect, then Sound Actions, and then Pause. This inserts a Pause animation into your animation sequence.

    Finally, set the Pause animation to be triggered when the user clicks your ‘Pause’ action button:

    1.      Select the Pause animation in the Custom Animation pane.

    2.      Right-click and select Timing.

    3.      On the Timing tab, click Triggers. Then click Start effect on click of, and select the action button from the pull-down list. Click OK.

    That should do it. Now, when the sound file plays, clicking the action button will pause the file playback. Clicking the button again starts the sound file from where it was paused.

    The end-user writers were also kind enough to suggest some online articles and trainings that cover these issues in more detail.

    Here’s an article that’s about triggers:

    Use triggers to create an interactive slide show in PowerPoint

    This course covers the new sounds options that were available in 2003:

    Playing Sound

    While the next link is to a course focused on video, its second lesson tells how to set up the button panel to play the video (sound, in this case).

    Playing movies

    And, as always, you can also check out the public PowerPoint newsgroup. It’s a great place to get quick answers for stuff like this.

    PowerPoint General Questions

  • Andrew May's WebLog

    Publisher Programming Made Easy: Types of Visual Basic Statements

    • 1 Comments

    I’m writing a series of articles for beginners on how to program the Publisher object model. These articles focus on the practical side of programming, and only go into enough conceptual detail to explain what the code is doing. So I thought I’d provide some more in-depth technical information for anyone interested.

    In the lessons, we mention that macros are actually Visual Basic procedures. Sub procedures, to be precise. Procedures are made up of code statements that contain the commands for the actions you want Visual Basic to perform. While we use almost all of the different kinds of statements through out the course of the lessons, I didn’t want to unnecessarily complicate things by calling out the types as we used them. So, if you’re interested, here’s the basics:

    VBA distinguishes four kinds of statements: declarations, assignment statements, executable statements, and compiler options.

    Declaration statement

    A statement that tells Visual Basic you intent to use a named item of the following types in your program:

    ·         Variable

    ·         Constant

    ·         User-defined type

    ·         Procedure

    For example:

    Dim MyNumber As Integer

    This declaration statement declares a variable (a named space in computer memory whose value that can change as the code is executed) named MyNumber and specifies it will always contain an integer.

    Constant ProductName = “Publisher”

    This declaration statement declares a constant (a named value that does not changes as the code is executed) named ProductName that consists of the character string “Publisher”.

    Assignment statement

    A statement that sets a variable or property of an object to a specific value. These statement always have three parts:

    Variable or property name = Expression specifying the new value

    For example, this statement:

    MyNextNumber = MyNumber + 12

    Sets the value of the MyNextNumber variable to the sum of the MyNumber variable plus 12.

    Border.Color = Blue

    Sets the Color property of the Border object to blue (blue is a named constant representing the numeric value of a particular color.)

    MySquareRoot = Sqr(MyNumber)

    Sets the value of the SquareRoot variable by calling the Sqr function and passing it the value of the MyNumber variable.

    When you’re assigning values to object variables, use the Set keyword:

    Set MyPage = Document.Pages(1)

    Executable statement

    A statement that executes the program’s instructions. Use executable statements to do the following:

    ·         Call another procedure in your own code

       MyProcedure

    ·         Activate a method belonging to an object

       Shape.Delete

    ·         Control the order in which other statements are executed

       If MyNumber = 5 Then

    ·         Execute one of the built-in VBA statement or functions

       UCase(“lowercase”)

    For example:

    If BorderArt.Exists = True Then
         BorderArt.Delete
    End If

    Two executable statements: The If…Then statement tests to see if the current value of the Exists property is True. If it is, the next method calls the Delete method.

    Compiler options

    Compiler options are commands that control how the compiler compiles your code. The compiler is the application that takes the human-readable code you write and turns it into the 1’s and 0’s the computer can understand. Compiler options go at the top of your project file. You probably won’t mess with compiler options much as you first start to program.

    For example:

    Option Explicit

    This compiler option tells the compiler that you have to declare each variable in your code (using a declaration statement) before you can use it in an assignment statement.

  • Andrew May's WebLog

    Publisher Programming Made Easy: Why Program with Objects, Anyway?

    • 3 Comments

    I’m writing a series of articles for beginners on how to program the Publisher object model. These articles focus on the practical side of programming, and only go into enough conceptual detail to explain what the code is doing.

    So I thought readers of those articles might have some questions about what’s really going on, and why programming is structured the way it is. As it happens, I gave a short presentation to the other Publisher technical writers on this subject a few years ago. So I dusted off my presentation, and I plan on excerpting some of the relevant portions in my next two entries.

    This stuff’ll be old hat to anyone who’s done basic object-oriented programming, but my hope is that it’ll answer some questions for people who haven’t and encourage them to get their feet wet.

    So, here’s today’s topic: why do we program using objects, anyway?

    The short answer is that, as programs get more complicated, objects provide several distinct advantages over the way programming has been done in the past. Object-oriented languages have three main characteristics that make them better to use than procedural programming languages: encapsulation, polymorphism, and inheritance.

    Encapsulation

    Objects package data and procedures into building blocks, based on real-world scenarios, with which to construct complex programs.

    Objects can be defined and maintained independent of one another. A change to one object does not affect another.

    Objects function as black boxes; their internal processes are invisible (and inaccessible) to other objects and code. They only respond to the messages defined for them.

     

     

     

     

     

     

     

     

    PropertyA

     

     

     

     

    ObjectA

    PropertyB

    < 

    Message

     

    ObjectB

     

    MethodA

     

    Return Data

    > 

     

     

    MethodB

     

     

     

     

     

     

     

     

     

     

     

    You cannot access the properties or methods of an object directly. You have to access the properties and methods by sending the object a message.

    A message is the name of an object, followed by the name of a method that the object knows how to perform, or a property the object has. For example:

    Page.Delete

    Note that we have no idea how the Page object performs the Delete method. We just know that when we send the following message, the Page object deletes itself. That’s the essence of encapsulation.

    Signature is the format the message must take in order to be understood by the object. Parameters (also sometimes called arguments) are any additional information the object must know in order to perform the method. Parameters may be required or optional. The message signature defines what information they get back (if any). This is also called the return type.

    A typical signature for an object method might look something like this:

    Object.Method(Parameter1, Parameter2) As ReturnType

    Transport.Travel (DepartureCity, ArrivalCity)

    Technically, parameter refers to the data type, while argument refers to the actual data value passed in a specific instance. But that’s splitting hairs. Most programmers use the terms interchangeably (and incorrectly).

    Programmers sometimes refer to the properties and methods of an object collectively as that object’s interface. That’s because those properties and methods are the only way you can interact with the object. The rest of its operations are hidden from us.

    An object’s interface (or message interface) is the collection of message signatures that object implements (performs). These signatures are the only way for other objects and code to access the object. The inner workings of each object is a ‘black-box’ to other objects; they cannot access the data in an object directly.

    Polymorphism

    Polymorphism refers to the ability of different objects to respond to the same message in different ways.

    Different objects can respond to the same message in different ways. This is because the procedure (i.e., the property or method) for that message has been defined within each object.

    To expand on our earlier example, here’s several objects, each of which implements a Travel method:

    Car.Travel(Chicago, Los Angeles)

    Plane.Travel(Chicago, Los Angeles)

    Boat.Travel(Chicago, Los Angeles)

    Bike.Travel(Chicago, Los Angeles)

    As you can see, each object would implement the Travel method in a very different way. But because the Travel method for each is contained in the object itself, it doesn’t matter. And you could add other objects later with their own Travel methods, and this does not effect the existing objects or procedures using those objects.

    Inheritance

    A class is the template that defines the methods and properties included in a particular type of object. An instance is an example of that object created (or instantiated) when the program is running. One way to think of it is this: the class is the blueprint, while the instance is the actual, specific house.

    A class: Page object

    Three instances: Page 1, Page 2, Page 3

    Classes can be based on other classes. This is called inheritance. The object based on other objects (usually called derived classes, or subclasses) inherit all the properties and methods of the first class (usually called base class, or superclass). However, they can substitute methods of their own for the superclass methods. They can also contain additional properties or methods.

    Classes can be nested to any depth, with subclasses inheriting all the methods and properties of the classes above it.

    The term virtual class refers to a class that other classes will be based on, but which will never actually be instantiated in the program.

    Note that Visual Basic 6.0 is not a completely object-oriented language, because it does not support inheritance. You cannot (really) base classes on other classes in VB or VBA 6.0. You can in VB.Net, however, which is one of the appeals of that language.

    Also, be aware that inheritance has nothing to do with how objects are structured in an object model. In an object model, objects that contain other objects are called parent object, while objects contained in other objects are referred to as children of the containing object. This has nothing to do with inheritance. The child objects do not inherit properties or methods from the parent objects. For example, in the Publisher object model, the Page object inherits none of its members from the Document object, which is one of its parents.

Page 1 of 1 (3 items)