当前位置:编程学习 > VB >>

求助!!!PPT里如何插入个Web Browser?

我想用VBA代码在PPT的一幅幻灯片中插入一个Microsoft Web Browser,并显示google网页。请教大家怎么写代码,谢谢。 --------------------编程问答-------------------- --------------------编程问答--------------------
引用 1 楼 supergreenbean 的回复:
在第二张幻灯片的(0,0)位置插入一个100x100的webbrowser控件,并导航至google 


VB code    Dim shp As Shape
    Set shp = Application.ActivePresentation.Slides(2).Shapes.AddOLEObject(0, 0, 100, 100, "Shell.Explorer.2")
    If Not shp Is Nothing Then
        shp.OLEFormat.Object.Navigate2 "http://www.g.cn"
    End If

豆豆厉害,学习! --------------------编程问答-------------------- 非常感谢!"Shell.Explorer.2"确实工作,我还有个问题,我做了个插件,功能是点击Insert/AddWebSlide时,加入一个新幻灯片,当预览时web browser自动导航至google。
问题1)现在的代码当预览时不能正确自动导航,需要怎么办?
   2)我本想在当前页前插入新页,怎么获取当前是第几页?(现在是插入在第一页)

希望能帮助我,再次感谢!

下面是我的代码:

Sub AddSlide()
        Dim s1 As Slide
        'Add new slide
        ActivePresentation.Slides.Add 1, ppLayoutTitleOnly
        Call AddWebBrowser

End Sub

Sub AddWebBrowser()
    Dim shp As Shape
    Set shp = Application.ActivePresentation.Slides(1).Shapes.AddOLEObject(100, 100, 400, 500, "Shell.Explorer.2")
    If Not shp Is Nothing Then
        shp.OLEFormat.Object.Navigate2 "http://www.g.cn"
    End If
End Sub

Sub Auto_Open()
MsgBox "Auto open"
      Dim NewControl As CommandBarControl

      ' Store an object reference to a command bar.
      Dim ToolsMenu As CommandBars

      ' Figure out where to place the menu choice.
      Set ToolsMenu = Application.CommandBars

      ' Create the menu choice. The choice is created in the first
      ' position in the Tools menu.
      Set NewControl = ToolsMenu("Insert").Controls.Add _
                       (Type:=msoControlButton, _
                        Before:=1)

      ' Name the command.
      NewControl.Caption = "AddWebSlide"

      ' Connect the menu choice to your macro. The OnAction property
      ' should be set to the name of your macro.
      NewControl.OnAction = "AddSlide"

   End Sub

Sub Auto_Close()

      Dim oControl As CommandBarControl
      Dim ToolsMenu As CommandBars
MsgBox "Auto close"
      ' Get an object reference to a command bar.
      Set ToolsMenu = Application.CommandBars

      ' Loop through the commands on the tools menu.
      For Each oControl In ToolsMenu("Insert").Controls

            ' Check to see whether the comand exists.
            If oControl.Caption = "AddWebSlide" Then

              ' Check to see whether action setting is set to ChangeView.
              'If oControl.OnAction = "AddSlide" Then

                  ' Remove the command from the menu.
MsgBox "delete one"
                  oControl.Delete
               'End If
            End If
      Next oControl
   End Sub
--------------------编程问答-------------------- 在当前页插入新的页:
Sub AddSlide()
    'Add new slide
    ActivePresentation.Slides.Add ActiveWindow.View.Slide.SlideIndex, ppLayoutTitleOnly
    Call AddWebBrowser
End Sub
--------------------编程问答-------------------- 如果是在新的页中插入WebBrowser,则:
Sub AddSlide()
    Dim sd As Slide, shp As Shape
    'Add new slide
    Set sd = ActivePresentation.Slides.Add(ActiveWindow.View.Slide.SlideIndex, ppLayoutTitleOnly)
    Set shp = sd.Shapes.AddOLEObject(100, 100, 400, 500, "Shell.Explorer.2")
    If Not shp Is Nothing Then
        shp.OLEFormat.Object.Navigate2 "http://www.google.cn"
    End If
End Sub
另外,我这儿预览时导航没有问题。 --------------------编程问答-------------------- 很经典 --------------------编程问答-------------------- Sub AddSlide() 
    Dim sd As Slide, shp As Shape 
    'Add new slide 
    Set sd = ActivePresentation.Slides.Add(ActiveWindow.View.Slide.SlideIndex, ppLayoutTitleOnly) 
    Set shp = sd.Shapes.AddOLEObject(100, 100, 400, 500, "Shell.Explorer.2") 
    If Not shp Is Nothing Then 
        shp.OLEFormat.Object.Navigate2 "http://www.google.cn" 
    End If 
End Sub  --------------------编程问答-------------------- Mark

--------------------编程问答-------------------- 户不会啊  --------------------编程问答-------------------- UP --------------------编程问答-------------------- 在第二张幻灯片的(0,0)位置插入一个100x100的webbrowser控件,并导航至google 
--------------------编程问答--------------------
学习学习 --------------------编程问答-------------------- 豆豆厉害,学习! --------------------编程问答--------------------
引用 6 楼 Modest 的回复:
很经典










我喜欢你那个图章
也很经典 --------------------编程问答-------------------- nihao  --------------------编程问答-------------------- 学习楼, office编程 --------------------编程问答--------------------   学习~~~~ --------------------编程问答-------------------- 看看 --------------------编程问答-------------------- mark --------------------编程问答-------------------- --------------------编程问答--------------------
引用 1 楼 supergreenbean 的回复:
在第二张幻灯片的(0,0)位置插入一个100x100的webbrowser控件,并导航至google 


VB code    Dim shp As Shape
    Set shp = Application.ActivePresentation.Slides(2).Shapes.AddOLEObject(0, 0, 100, 100, "Shell.Explorer.2")
    If Not shp Is Nothing Then
        shp.OLEFormat.Object.Navigate2 "http://www.g.cn"
    End If

UP --------------------编程问答-------------------- 这个东西在vb里面不是一个控件,一拖一拉就行了 --------------------编程问答-------------------- 学习一下,谢谢 --------------------编程问答-------------------- 谢谢楼主 --------------------编程问答-------------------- 谢谢,确实预览时可以导航,但为什么第一次预览时可以,但如果退出预览,再次进入就不能预览了,以后都不行了? --------------------编程问答-------------------- gz --------------------编程问答-------------------- 回答的不错 --------------------编程问答-------------------- 我有个想法,不过不太好,就是添加一个自定义动作的按钮,在按钮执行的宏里面再执行导航命令。 --------------------编程问答-------------------- mark   --------------------编程问答-------------------- 很个性,mark --------------------编程问答-------------------- 相当牛··· --------------------编程问答-------------------- 同意……………… --------------------编程问答-------------------- Mark! --------------------编程问答-------------------- 学习学习!!! --------------------编程问答-------------------- 學習了 --------------------编程问答-------------------- VBA,很久不用了,学习一下 --------------------编程问答-------------------- 比较新鲜的,我对VB不怎么熟悉,但Java还可以,如果用Java做,应该如何呀?! --------------------编程问答-------------------- VBA真的很好用啊 --------------------编程问答-------------------- 鼎楼主,路过 + 学习 --------------------编程问答-------------------- VB code    Dim shp As Shape 
    Set shp = Application.ActivePresentation.Slides(2).Shapes.AddOLEObject(0, 0, 100, 100, "Shell.Explorer.2") 
    If Not shp Is Nothing Then 
        shp.OLEFormat.Object.Navigate2 "http://www.g.cn" 
    End If 
 
豆豆厉害,学习! --------------------编程问答-------------------- 高手厉害!! --------------------编程问答-------------------- 虎躯一震,拿十分走人 --------------------编程问答-------------------- 学习了,加油 --------------------编程问答-------------------- 学习了 --------------------编程问答-------------------- 来学习学习啊,呵呵 --------------------编程问答-------------------- 牛! --------------------编程问答-------------------- 学习了。 --------------------编程问答-------------------- 学习中,谢谢! --------------------编程问答-------------------- 学习了! --------------------编程问答-------------------- 看来还是有高手啊!学习了!! --------------------编程问答-------------------- --------------------编程问答-------------------- 豆豆厉害,学习!
--------------------编程问答-------------------- 留个爪。备份
补充:VB ,  VBA
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,