Microsoft KB Archive/253699

= PPT2000: How to Use the WebBrowser Control on a Slide =

Article ID: 253699

Article Last Modified on 7/23/2007

-

APPLIES TO


 * Microsoft PowerPoint 2000 Standard Edition

-



This article was previously published under Q253699



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



SUMMARY
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.



MORE INFORMATION
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 = "http://www.microsoft.com" 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:  Right-click the WebBrowser control, and click View code on the shortcut menu. The Visual Basic Editor opens with the Slide  project selected, where   is the index value of the slide where you added the ActiveX control.  In the Procedure list, click DocumentComplete.

When you do this, Visual Basic for Applications automatically adds the following code into the slide: Sub _DocumentComplete(ByVal pDisp As Object, URL As Variant)

End Sub Where  represents the unique name of the WebBrowser control.   Modify the subroutine above so that it looks as follows: Sub _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 = "http://www.microsoft.com" WebBrowser1.Navigate varURL End If End Sub  Close the Visual Basic Editor.</li></ol>

<div class="references_section">