PowerPoint automation

G

Galin Iliev

Hello folks,
I am trying to read all opened presentation in working Powerpoint instance.
and then to make some modification on some of then.
For this purpose I would like to open another instance of PowerPoint but it
doesn't work.
here is result
when I have the same situation with MS Excel everything is as I expect:
I have running process of excel.exe
and when I execute line
set ExcelVar = CreateObject("Excel.Applicaton")
I have two processes of excel.exe

however, with PowerPoint there is no difference between if I use
set PowerPoint Var = CreateObject("PowerPoint .Applicaton")
or
set PowerPoint Var = GetObject(,"PowerPoint .Applicaton")

Can someone explain me why this happens and how I cand solve this issue?
Thank you in advance

Galin Iliev
MCSD
 
E

eric23

I think powerpoint can ony run as one instance
(try launching multiple versions from windows startmenu -- I couldnt on
2003)
Its different from the other office apps
maybe there is a way of opening multiple files in the one app to do what you
want?
 
H

Howard Kaikow

I do not believe that there can be a 2nd instance of Powerpoint.
I ran there following in Word 2003.
===================================
Option Explicit

Public Sub MultiplePowerpoints()
Dim appPowerpoint As PowerPoint.Application
Dim appPowerpointAnother As PowerPoint.Application
Dim appWord As Word.Application
Dim blnPPTRunning As Boolean

On Error Resume Next
Set appPowerpoint = GetObject(Class:="PowerPoint.Application")
If appPowerpoint Is Nothing Then
' Powerpoint not running, create instance of Powerpoint
blnPPTRunning = False
Err.Clear
Set appPowerpoint = New PowerPoint.Application
MsgBox "Creating first instance of Powerpoint", vbOKOnly,
"Powerpoint was not already running"
Else
blnPPTRunning = True
MsgBox "Using running instance of Powerpoint", vbOKOnly, "Powerpoint
was already running"
End If
With appPowerpoint
.Visible = msoTrue
.WindowState = ppWindowMinimized
End With
' Create another instance of Powerpoint
Set appPowerpointAnother = New PowerPoint.Application
If appPowerpointAnother Is Nothing Then
With Err
MsgBox .Number & ": " & .Description, vbOKOnly, "Could not
create second instance of Powerpoint"
End With
Else
MsgBox "OK!", vbOKOnly, "Created second instance of Powerpoint"
With appPowerpointAnother
.Visible = msoTrue
.WindowState = ppWindowMinimized
End With
End If

'If this code started PowerPoint
If blnPPTRunning = False Then
If vbYes = MsgBox("Select Yes to kill the First instance of
Powerpoint", vbYesNo, _
"Powerpoint hit squad needs your instructions") Then
appPowerpoint.Quit
End If
End If

If vbYes = MsgBox("Select Yes to kill the second instance of
Powerpoint", vbYesNo, _
"Powerpoint hit squad needs your instructions") Then
appPowerpointAnother.Quit
End If

' Create another instance of Word
' Do not kill
Set appWord = New Word.Application
If appWord Is Nothing Then
With Err
MsgBox .Number & ": " & .Description, vbOKOnly, "Could not
create second instance of Word"
End With
Else
MsgBox "OK!", vbOKOnly, "Created second instance of Word"
With appWord
.Visible = msoTrue
.WindowState = wdWindowStateMinimize
End With
End If

Set appPowerpoint = Nothing
Set appPowerpointAnother = Nothing
Set appWord = Nothing
End Sub
 
G

Galin Iliev

Hello Howard Kaikow,
I have modified a little bit your procedure. As result I get same process
could you try it and see what happens.
I get same windows handle and processID for both PowerPoint instances

Note: I am with PowerPoint XP

Thank you for cooperation

Galin Iliev
MCSD

Option Explicit

Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd
As Long, lpdwProcessId As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Public Sub MultiplePowerpoints()
Dim appPowerpoint As PowerPoint.Application
Dim appPowerpointAnother As PowerPoint.Application
Dim appWord As Word.Application
Dim blnPPTRunning As Boolean
Dim lFirstID As Long
Dim lSecondID As Long
Dim lFirstHandle As Long
Dim lSecondHandle As Long

On Error Resume Next
Set appPowerpoint = GetObject(Class:="PowerPoint.Application")
If appPowerpoint Is Nothing Then
' Powerpoint not running, create instance of Powerpoint
blnPPTRunning = False
Err.Clear
Set appPowerpoint = New PowerPoint.Application
MsgBox "Creating first instance of Powerpoint", vbOKOnly, _
"Powerpoint was not already running"
Else
blnPPTRunning = True
MsgBox "Using running instance of Powerpoint", vbOKOnly, "Powerpoint
was already running"
End If
With appPowerpoint
.Visible = True
.Activate
lFirstHandle = GetForegroundWindow()
.WindowState = ppWindowMinimized
End With
' Create another instance of Powerpoint
Set appPowerpointAnother = New PowerPoint.Application
If appPowerpointAnother Is Nothing Then
With Err
MsgBox .Number & ": " & .Description, vbOKOnly, "Could not
create second instance of Powerpoint"
End With
Else
MsgBox "OK!", vbOKOnly, "Created second instance of Powerpoint"
With appPowerpointAnother
.Visible = True
.Activate
lSecondHandle = GetForegroundWindow()
.WindowState = ppWindowMinimized
End With
End If

'Check processes IDs
GetWindowThreadProcessId lFirstHandle, lFirstID
GetWindowThreadProcessId lSecondHandle, lSecondID
If lFirstID = lSecondID Then MsgBox "appPowerpoint and appPowerpoint
hold same process!"

'If this code started PowerPoint
If blnPPTRunning = False Then
If vbYes = MsgBox("Select Yes to kill the First instance of
Powerpoint", vbYesNo, _
"Powerpoint hit squad needs your instructions") Then
appPowerpoint.Quit
End If
End If

If vbYes = MsgBox("Select Yes to kill the second instance of
Powerpoint", vbYesNo, _
"Powerpoint hit squad needs your instructions") Then
appPowerpointAnother.Quit
End If

' Create another instance of Word
' Do not kill
Set appWord = New Word.Application
If appWord Is Nothing Then
With Err
MsgBox .Number & ": " & .Description, vbOKOnly, "Could not
create second instance of Word"
End With
Else
MsgBox "OK!", vbOKOnly, "Created second instance of Word"
With appWord
.Visible = True
.WindowState = wdWindowStateMinimize
End With
End If

Set appPowerpoint = Nothing
Set appPowerpointAnother = Nothing
Set appWord = Nothing
End Sub
 
H

Howard Kaikow

Same result in Office 2003.
I used code as modified below:

Option Explicit

Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd
As Long, lpdwProcessId As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Public Sub MultiplePowerpointsHandles()
Dim appPowerpoint As Powerpoint.Application
Dim appPowerpointAnother As Powerpoint.Application
Dim appWord As Word.Application
Dim blnPPTRunning As Boolean
Dim lngHandle1 As Long
Dim lngHandle2 As Long
Dim lngHandleWord As Long
Dim lngPID1 As Long
Dim lngPID2 As Long

lngHandleWord = GetForegroundWindow()
On Error Resume Next
Set appPowerpoint = GetObject(Class:="PowerPoint.Application")
If appPowerpoint Is Nothing Then
' Powerpoint not running, create instance of Powerpoint
blnPPTRunning = False
Err.Clear
Set appPowerpoint = New Powerpoint.Application
MsgBox "Creating first instance of Powerpoint", vbOKOnly, _
"Powerpoint was not already running"
Else
blnPPTRunning = True
MsgBox "Using running instance of Powerpoint", vbOKOnly, "Powerpoint
was already running"
End If
With appPowerpoint
.Visible = True
.Activate
lngHandle1 = GetForegroundWindow()
.WindowState = ppWindowMinimized
End With
' Create another instance of Powerpoint
Set appPowerpointAnother = New Powerpoint.Application
If appPowerpointAnother Is Nothing Then
With Err
MsgBox .Number & ": " & .Description, vbOKOnly, "Could not
create second instance of Powerpoint"
End With
Else
MsgBox "OK!", vbOKOnly, "Created second instance of Powerpoint"
With appPowerpointAnother
.Visible = True
.Activate
lngHandle2 = GetForegroundWindow()
.WindowState = ppWindowMinimized
End With
'Check processes IDs
GetWindowThreadProcessId lngHandle1, lngPID1
GetWindowThreadProcessId lngHandle2, lngPID2
If lngPID1 = lngPID2 Then
MsgBox "Both instances of Powerpoint use the same process.",
vbOKOnly, _
"Powerpoint"
Else
MsgBox "Each instance of Powerpoint uses a different
process.", vbOKOnly, _
"Powerpoint"
End If

If vbYes = MsgBox("Select Yes to kill the second instance of
Powerpoint", vbYesNo, _
"Powerpoint hit squad needs your instructions") Then
appPowerpointAnother.Quit
End If
End If

'If this code started PowerPoint
If blnPPTRunning = False Then
If vbYes = MsgBox("Select Yes to kill the First instance of
Powerpoint", vbYesNo, _
"Powerpoint hit squad needs your instructions") Then
appPowerpoint.Quit
End If
End If

' Create another instance of Word
Set appWord = New Word.Application
If appWord Is Nothing Then
With Err
MsgBox .Number & ": " & .Description, vbOKOnly, "Could not
create second instance of Word"
End With
Else
MsgBox "OK!", vbOKOnly, "Created second instance of Word"
With appWord
.Visible = True
.Activate
lngHandle2 = GetForegroundWindow()
.WindowState = wdWindowStateMinimize
'Check processes IDs
GetWindowThreadProcessId lngHandleWord, lngPID1
GetWindowThreadProcessId lngHandle2, lngPID2
If lngPID1 = lngPID2 Then
MsgBox "Both instances of Word use the same process.",
vbOKOnly, _
"Word"
Else
MsgBox "Each instance of Word uses a different process.",
vbOKOnly, _
"Word"
End If
.Quit
End With
End If

Set appPowerpoint = Nothing
Set appPowerpointAnother = Nothing
Set appWord = Nothing
End Sub
 
G

Galin Iliev

Howard Kaikow,
Thank you for cooperation.
Now I know there is no way to create second instances of PowerPoint (all
Versions ;) )
I'll start looking for some walkarounds for my purposes.

Galin Iliev
MCSD
 
T

Tushar Mehta

http://www.rdpslides.com/pptfaq/FAQ00280.htm should help you understand
what is going on, and what your choices are.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

I installed Microsoft Office 2000 a couple years ago. I never really used it b/c it was on my home computer and I rarely turned my home computer on.

Here's the deal. I recently took on a new job which requires me to use a ton of power point presentations. I'm supposed to work on them at home, etc. I've recently tried opening some ppt presentations over email and was not able to doe so. Long story short, I determined that although I have word, excel, access, etc etc, I do NOT have ppt on my computer. I removed and installed the Microsoft disc I have
several times and still NO POWERPOINT. Can someone help me.
 
A

Amedee Van Gasse

Tushar Mehta <mailto:[email protected]> leverde op 28
jun 2004 een briljante bijdrage in
<Klik op deze link om het
bericht in zijn oorspronkelijke context te lezen:
http://www.rdpslides.com/pptfaq/FAQ00280.htm should help you understand
what is going on, and what your choices are.

So if you have either of these:

Office 2000 Developer, Office 2000 Premium, Office 2000 Professional,
Office 2000 Small Business Edition, Office 2000 Standard

you can get Powerpoint 2003 for 109 US$ or 89.26 EUR.

--
Amedee Van Gasse
http://www.amedee.be

Dit bericht is geplaatst in een nieuwsgroep. Post je evt antwoord of
vervolgvraag graag in dezelfde thread in de nieuwsgroep a.u.b.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top