Microsoft KB Archive/253699

From BetaArchive Wiki

Article ID: 253699

Article Last Modified on 7/23/2007


  • Microsoft PowerPoint 2000 Standard Edition

This article was previously published under Q253699

For a Microsoft PowerPoint 2002 version of this article, see 291926.


The code in this article demonstrates how to display a live Web page on a slide during a PowerPoint slide show, using the Microsoft WebBrowser ActiveX control.


Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. NOTE: The following macro examples work only in PowerPoint. Visual Basic for Applications macros are not supported by the Microsoft PowerPoint Viewer. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

Adding the Control

To add a Microsoft WebBrowser control to a slide, follow these steps:

  1. Go to the slide where you want to insert the control.
  2. If the Control Toolbox is not already visible, point to Toolbars on the View menu, and then click Control Toolbox.
  3. Click the More Controls button in the Control Toolbox. Click Microsoft Web Browser, and then draw the control on your slide.

The Microsoft WebBrowser ActiveX control now appears on your slide.

Run from an Action Button

The following code runs the browser, opening the Uniform Resource Locator (URL) that you specify:

Sub go2URL()
   Dim varURL As Variant
   varURL = ""
   WebBrowser1.Navigate varURL
End Sub

To run this code, you have to add an action button to the slide to activate the macro:

  1. On the Drawing toolbar, click AutoShapes; point to Action Buttons, and click the Action Button: Custom button (the button that is blank).
  2. Draw the button in a suitable location on your slide.

When you finish drawing the button, the Action Settings dialog box appears. The default action for this button is None.

  1. Click Run Macro and then click the go2URL macro.

Automatically Load Web Page on Slide

The following procedure allows you to automatically load the URL when you display the slide on the screen:

  1. Right-click the WebBrowser control, and click View code on the shortcut menu.
  2. The Visual Basic Editor opens with the Slide n project selected, where n is the index value of the slide where you added the ActiveX control.
  3. In the Procedure list, click DocumentComplete.

    When you do this, Visual Basic for Applications automatically adds the following code into the slide:

    Sub <WebBrowserN>_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    End Sub

    Where <WebBrowserN> represents the unique name of the WebBrowser control.

  4. Modify the subroutine above so that it looks as follows:

    Sub <WebBrowserN>_DocumentComplete(ByVal pDisp As Object, URL As Variant)
       Dim varURL As Variant
    ' Check to see if this is the first time this
    ' control has been run, if so, load the page.
       If URL = "" Then
          varURL = ""
          WebBrowser1.Navigate varURL
       End If
    End Sub
  5. Close the Visual Basic Editor.


For more information about the Microsoft WebBrowser Control, click the following hyperlink

which is on the Microsoft Developers Network.

For additional information about using the WebBrowser Control, click the article numbers below to view the articles in the Microsoft Knowledge Base:

176400 HOWTO: Print the WebBrowser Control

155969 HOWTO: Distribute the WebBrowser Control

174923 HOWTO: Use the PostData Parameter in WebBrowser Control

Additional query words: vba pp2k ppt2k www autoload Web browser

Keywords: kbdtacode kbhowto KB253699