Results 1 to 8 of 8
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Showing slides in a OleContainer (2000)

    Hi!

    I have an ole container where I want to show a Powerpoint presentation (inside). That code to get this is the following:

    OLE1.CreateEmbed ("c:MyPresentation.ppt")
    OLE1.DoVerb (ovOpen)

    Now, I would like to go to a different slide, pressing a button on my form. Is possible to do this?
    I am pretty new with OLE, so I'd appreciate some help or code example

    Thanks a lot

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Showing slides in a OleContainer (2000)

    Luis, you need to use the Windows API to do this. I've found a brief note from Microsoft's MVP Shyam Pillai:

    <img src=/w3timages/blackline.gif width=33% height=2>
    1. Temporarily lock the desktop to prevent flashing (Use API -LockWindow & GetDesktopWindow)
    2. Start the slide show and locate the slide show window (class: -ScreenClass) (use API -FindWindow)
    3. Pass the handle obtained and the VB form handle to SetParent to place the slide show window within the vb form.
    4. Resize the slide show window.
    5. Unlock the desktop update

    That should do it. Use Points for measurement since PowerPoint uses it as it's unit for measurement, makes it easier.
    <img src=/w3timages/blackline.gif width=33% height=2>

    This is Sam again: hope you can understand that. I wish that there were more details, but if I get time, I'm going to try to implement it and I'll post my code. If you get it done first, I'd appreciate it if you would post your code. Once we get Shyam's suggestion running, then I assume that if we use the VB button to advance (the Next method, I think) the "actual" slide show (ie not the one in the OLE container), then the OLE container will also get updated. Thanks! --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    Star Lounger
    Join Date
    Apr 2002
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Showing slides in a OleContainer (2000)

    Hi Sam,

    Once again, your help has been very useful. However, it doesn't seem to be too simple to do it, for that reason and because I need to finish this as soon as possible, I've had to remove the OLE container, and open the slide in Powerpoint when you click on it, showing the slide that I want. It's ugly, but I am a little bit behind in this project, and I had to use this solution.

    Anyway, if you guess something, just let me know. I didn't think that was going to be so difficult, because I could use the GotoSlide method that the object provides (ActiveWindow.View.GotoSlide)

    Thanks a lot, Sam

    Luis

  4. #4
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Showing slides in a OleContainer (2000)

    That will be much faster to implement. You can also make a separate form for the "next" button and always keep it on top. Let me know if you need help using OLE Automation to start PoPo and/or goto the next slide. Be sure to use Project | References menu to add the Microsoft PowerPoint Object library. I think that your start-up code will look like:
    <pre>Dim ppApp As PowerPoint.Application
    Dim ppPres As PowerPoint.Presentation
    Dim ppShow As String
    ppShow = "cocuments and SettingsbarretskMy Documentstest.pps"
    Set ppApp = CreateObject("PowerPoint.Application")
    Set ppPres = ppApp.Presentations.Open(ppShow, , , False)
    ppPres.SlideShowSettings.Run
    Do While ppApp.SlideShowWindows.Count > 0
    DoEvents
    Loop
    Set ppPres = Nothing
    DoEvents
    ppApp.Quit
    DoEvents
    Set ppApp = Nothing</pre>


    Unfortunately, I don't have time to test it.

    The Next-button code is:
    <pre> ppApp.SlideShowWindows(1).View.GotoSlide i
    i = i+1</pre>


    If I get time, I'll test it tonight. --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  5. #5
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Showing slides in a OleContainer (2000)

    Here's the form code for running PowerPoint via OLE Automation. Open a new VB project and double click on the button tool in the toolbox, so that you have a single button in the middle of the form. Use the Project | References to add the Microsoft PowerPoint object library.

    Now copy the code below, paste it into Word, select all, and copy the code from Word. This gets rid of HTML formatting.

    Finally, switch back to VB, double-click on the command button, select the entire code window, and replace it by pasting the code from above.

    Save the project and move the PowerPoint file to the same directory as the VB project. Finally, run the VB app. Have fun! --Sam

    <pre>Option Explicit
    Dim ppApp As PowerPoint.Application
    Dim ppPres As PowerPoint.Presentation
    Dim intSlide As Integer
    Dim savFTop As Long, savFLeft As Long
    Dim savCTop As Long, savCLeft As Long
    Dim savFHeight As Long, savFWidth As Long

    Private Sub Command1_Click()
    Dim ppShow As String
    If Command1.Caption <> "Next" Then
    ppShow = App.Path & "test.ppt"
    Set ppApp = CreateObject("Powerpoint.Application")
    ppApp.Visible = True
    Set ppPres = ppApp.Presentations.Open(ppShow, True, , True)
    ppPres.SlideShowSettings.Run
    Command1.Caption = "Next"
    savCLeft = Command1.Left
    savCTop = Command1.Top
    Command1.Left = 0
    Command1.Top = 0
    savFTop = Form1.Top
    savFLeft = Form1.Left
    savFHeight = Me.Height
    savFWidth = Me.Width
    Me.Width = 1700
    Me.Height = 900
    Me.Left = 1000
    Me.Top = Screen.Height - 1000
    intSlide = 1
    DoEvents
    Command1.SetFocus
    Else
    intSlide = intSlide + 1
    ppApp.SlideShowWindows(1).View.GotoSlide intSlide
    End If
    If intSlide = ppPres.Slides.Count Then
    ppPres.Close
    ppApp.Quit
    Set ppPres = Nothing
    Set ppApp = Nothing
    Me.Left = savFLeft
    Me.Top = savFTop
    Me.Width = savFWidth
    Me.Height = savFHeight
    Command1.Left = savCLeft
    Command1.Top = savCTop
    End If
    End Sub</pre>

    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  6. #6
    Star Lounger
    Join Date
    Apr 2002
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Showing slides in a OleContainer (2000)

    Sam,

    Thanks a lot for your help and for this wonderful example. That works great. Also, the examples that you sent me sometime ago to my email address, have been of a great help, to learn the basics of the PP automation.

    Thanks for share all your knowledge with us

    Take care,
    Luis

  7. #7
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Showing slides in a OleContainer (2000)

    Yes, but we still have to get that OLE container to work!
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  8. #8
    Star Lounger
    Join Date
    Apr 2002
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Showing slides in a OleContainer (2000)

    hehehe... yes! I'll let you know if I get something! [img]/forums/images/smilies/smile.gif[/img]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •