Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Set a powerpoint presentation as the application.activepresentatio

1 view
Skip to first unread message

ejtay

unread,
Mar 3, 2010, 6:51:01 PM3/3/10
to
Hi.. Can somebody please advice me on how to set a powerpoint presentation as
the powerpoint.application.activepresentation?

In the program below, when the form is loading, it will open 2 powerpoint
files (Test1.ppt and Test2.ppt). After Test2.ppt is opened, it will be the
activepresentation because it is opened last.

What I am trying to do is when I press button1, it will set Test1.ppt as
activepresentation so that when I press button4, it will show me
"C:\Test1.ppt".

The same also goes to button2 making Test2.ppt as activepresentation

But what I get is, no matter how many times i press button1, Test2.ppt is
always the activepresentation.

Can somebody help me please.. Thanks.

Imports PowerPoint = Microsoft.Office.Interop.PowerPoint
Public Class Form1
Dim oApp As New PowerPoint.Application
Dim oPres As PowerPoint.Presentation
Dim oSlide As PowerPoint.Slide
Dim FileLocation1 As String = "C:\Test1.ppt"
Dim FileLocation2 As String = "C:\Test2.ppt"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
oApp = New PowerPoint.Application
oApp.Visible = Microsoft.Office.Core.MsoTriState.msoTrue
oPres = oApp.Presentations.Open(FileLocation1)
oPres = oApp.Presentations.Open(FileLocation2)
End Sub

'looping to get presentation index where the presentation's fullname match
with FileLocation1
'Try to make Test1.ppt as activeapplication by using the index obtained
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim cntPres As Integer
For cntPres = 1 To oApp.Presentations.Count
If oApp.Presentations(cntPres).FullName = FileLocation1 Then
oApp.Presentations(cntPres).Application.Activate()
Exit For
End If

Next
End Sub

'looping to get presentation index where the presentation's fullname match
with FileLocation2
'Try to make Test2.ppt as activeapplication by using the index obtained
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim cntPres As Integer
For cntPres = 1 To oApp.Presentations.Count
If oApp.Presentations(cntPres).FullName = FileLocation2 Then
oApp.Presentations(cntPres).Application.Activate()
Exit For
End If
Next
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
MsgBox(oApp.Presentations.Count.ToString)
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
MsgBox(oApp.ActivePresentation.FullName)
End Sub
End Class

Steve Rindsberg

unread,
Mar 8, 2010, 10:11:01 PM3/8/10
to
In article <A2A10C7E-A9B4-41CF...@microsoft.com>, Ejtay wrote:
> Hi.. Can somebody please advice me on how to set a powerpoint presentation as
> the powerpoint.application.activepresentation?

Sub MakeActive()

Dim oPres As Presentation

For Each oPres In Presentations
Debug.Print oPres.Name
If UCase(oPres.Name) = "YOURPRESNAME.PPT" Then
oPres.Windows(1).Activate

0 new messages