tomor
tomor

Reputation: 1765

WebBrowser control zoomed out inside PowerPoint Slide

I need to have a WebBrowser control, set to a specific URL, embedded in a PowerPoint slide. I've gone with

Shape shape =    s.Shapes.AddOLEObject(0.0f, 0.0f, 720f, 540f, "Shell.Explorer.2", "", MsoTriState.msoFalse, "", -1, "", MsoTriState.msoFalse);

shape.OLEFormat.Object.Navigate2("http://www.google.com");

So far so good, it works perfectly well. However, I need to refresh the page every time the slides change during presentation. For this reason, I am doing something as follows to refresh the page:

    void Application_SlideShowNextSlide(SlideShowWindow Wn)
    {
        Slide sl = Wn.View.Slide;
        foreach (Shape s in sl.Shapes)
        {
            if (s.Type == Office.MsoShapeType.msoOLEControlObject) {
                if (s.OLEFormat.Object is SHDocVw.IWebBrowser2) {
                    SHDocVw.IWebBrowser2 wb = s.OLEFormat.Object as SHDocVw.IWebBrowser2;
                    object url = (object)"http://google.com/";
                    wb.Navigate2(url);
                } 
            }
        }
    }

The page is refreshed correctly. However, what is different now is that the page is automatically zoomed-out, so the page fits inside the control. Even if I make the control smaller, the page gets zoomed-out even more, to fit inside it.

Upvotes: 0

Views: 818

Answers (2)

tomor
tomor

Reputation: 1765

I've solved this problem by creating a custom User Control, and inserting a WebControl into it. Then, I've made the control "COM Visible", and thus, I can include it flawlessly inside PowerPoint, by using its ProgId.

Upvotes: 1

Peter Trypsteen
Peter Trypsteen

Reputation: 179

That's because you change all the shapes on the slide into that control including the slide itself. You need to add a way to differentiate between your control and other controls. Just checking if something is, has an OLE control object is not sufficient.

http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.oleobject_properties%28v=vs.90%29.aspx You could use the application property or the name or other to compare things. (Other choice is size, combination)

Upvotes: 0

Related Questions