A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Powerpoint, Publisher and Visio » Powerpoint
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Is Powerpoint still a single instance app?



 
 
Thread Tools Display Modes
  #91  
Old June 13th, 2005, 02:00 PM
Mike M.
external usenet poster
 
Posts: n/a
Default

When I want to let go of my PowerPoint instance in c++ I just call the
Release member. I don't do a quit. I start it up by doing a CreateInstance
of PowerPoint. Prior to 2002 there seemed to be a problem with reference
counting because my predecessor had commented out the code to do the release
with a notation about having trouble restarting another instance. I
implemented PowerPoint 2002 and put the release code back in and it worked
as expected.

"Steve Rindsberg" wrote in message
...
It appears t hat it ids NOT necessary to Quit a New instance of PPT

created
by code, except in one circumstance I will describe below. If one just

sets
the app object = Nothing and exits the code, the right thing happens in

all
but 1 circumstance.


2 perhaps. Instances started by code may not go away when you set the

object =
Nothing in PPT97 (and 2000 ... right, Mike?)

The problem occurs only when another use of PPT is started IN CODE and

that
use is not visible. In thiscase, setting the app for the New instance =
nothing also kills the other non-visble instance started by code.

Note that if the other instance started by code is visible, then there's

no
problem. Presentation count can even be 0.

This requires further investigation.


And less hair ... ;-)


-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================




  #92  
Old June 13th, 2005, 06:38 PM
Howard Kaikow
external usenet poster
 
Posts: n/a
Default

"Mike M." wrote in message
...
When I want to let go of my PowerPoint instance in c++ I just call the
Release member. I don't do a quit. I start it up by doing a

CreateInstance
of PowerPoint. Prior to 2002 there seemed to be a problem with reference
counting because my predecessor had commented out the code to do the

release
with a notation about having trouble restarting another instance. I
implemented PowerPoint 2002 and put the release code back in and it worked
as expected.


Ayup, I was looking into using the CreateInstance stuff, but I consider that
to be a poor choice.

PPT seems to kill the process as needed.
If there's a bug in any particular PPT version, too bad, attempting to
program around such an issue is not appropriate, as one cannot determine
whether other uses of PPT have started.

Everything I've ever seen states that the ONLY thing one can count on with
reference counts is whether they are 0 or knot.


  #93  
Old June 13th, 2005, 07:34 PM
Howard Kaikow
external usenet poster
 
Posts: n/a
Default

The bottom line.

The thing that get me sucked into this topic was a decision I made about
two months ago to include, in a VB 6 DLL, code for some Word macros that do
something with PPT via Automation.

In the DLL, for each Word macro, I've got code such as:

Public Sub DoWhateverWithPPT()
Dim appPPT As PowerPoint.Application

'Get existing instance of PowerPoint; otherwise create a new
one
' Powerpoint is a single instance application
On Error Resume Next
Set appPPT = GetObject(, "PowerPoint.Application")
If Err.Number 0 Then
Set appPPT = New PowerPoint.Application
End If
On Error GoTo 0

' He Do whatever with PPT

With appPPT
.ActivePresentation.Close
End With
End Sub

The PowerPoint process is created, and then removed from Task Manager,
wihout my using Quit or = Nothing as soon as the macro completes.

Why?
I expect because appPPT has scope local to the Sub and the reference goes
away when the Sub is exited.
If I were to fiddle around with Quit or = Nothing, then the code would risk
affecting other NON-VISIBLE uses of PPT that may have started AFTER a NEW
instance was created by the code. They may be affected anyway, but there's
nothing I can do about that as I cannot detect the other uses.


  #94  
Old June 14th, 2005, 02:44 PM
Steve Rindsberg
external usenet poster
 
Posts: n/a
Default

In article , Howard Kaikow wrote:
The bottom line.

The thing that get me sucked into this topic was a decision I made about
two months ago to include, in a VB 6 DLL, code for some Word macros that do
something with PPT via Automation.

In the DLL, for each Word macro, I've got code such as:

Public Sub DoWhateverWithPPT()
Dim appPPT As PowerPoint.Application

'Get existing instance of PowerPoint; otherwise create a new
one
' Powerpoint is a single instance application
On Error Resume Next
Set appPPT = GetObject(, "PowerPoint.Application")
If Err.Number 0 Then
Set appPPT = New PowerPoint.Application
End If
On Error GoTo 0

' He Do whatever with PPT

With appPPT
.ActivePresentation.Close
End With
End Sub

The PowerPoint process is created, and then removed from Task Manager,
wihout my using Quit or = Nothing as soon as the macro completes.

Why?
I expect because appPPT has scope local to the Sub and the reference goes
away when the Sub is exited.
If I were to fiddle around with Quit or = Nothing, then the code would risk
affecting other NON-VISIBLE uses of PPT that may have started AFTER a NEW
instance was created by the code. They may be affected anyway, but there's
nothing I can do about that as I cannot detect the other uses.



Not the solution you'd hoped for, but it ends up being a good deal simpler than
what you'd expected it to be. I guess that's A Good Thing?
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================


  #95  
Old June 14th, 2005, 10:00 PM
Howard Kaikow
external usenet poster
 
Posts: n/a
Default

"Steve Rindsberg" wrote in message
...

Not the solution you'd hoped for, but it ends up being a good deal simpler

than
what you'd expected it to be. I guess that's A Good Thing?


It's not quite the solution I had hoped for.

For example, in a VB 6 class that needs an insrance of Excel or Word, I'd
create that instance and keep it alive for the life of the class.

Not sure I can do that with PPT because there's a chance somebody might
start another use while the class is still running.

I guess that I could keep the object alive for the life of the class, but,
as of now, I feel uncomfortable doing that.

At least I do not have to worry about PPT 97. One of the Word macros will
not run in Word 97, so I'm not going to support the DLL for Word 97.


  #96  
Old June 15th, 2005, 03:48 AM
Steve Rindsberg
external usenet poster
 
Posts: n/a
Default

Not sure I can do that with PPT because there's a chance somebody might
start another use while the class is still running.


Luckily, in most cases that will also create another presentation, so you can
trap a lot of the ugliness based on presentation count. Not perfect, but ...
well. What is?


-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================


  #97  
Old June 15th, 2005, 05:32 PM
Howard Kaikow
external usenet poster
 
Posts: n/a
Default

"Steve Rindsberg" wrote in message
...
Not sure I can do that with PPT because there's a chance somebody might
start another use while the class is still running.


Luckily, in most cases that will also create another presentation, so you

can
trap a lot of the ugliness based on presentation count. Not perfect, but

....
well. What is?


Presentation count is not relevant.

The only thing relevant is whether the PPT use is visible,


  #98  
Old June 16th, 2005, 04:43 AM
Howard Kaikow
external usenet poster
 
Posts: n/a
Default

The following seems to do the deed, where appPPT is a PPT object with scope
of the class, and the following code is included in each procedure that
needs PPT.

appPPT is never Quit nor set = Nothing.

If TypeName(appPPT) "Application" Then
'Get existing instance of PowerPoint; otherwise create a
new one
' Powerpoint is a single instance application
On Error Resume Next
Set appPPT = GetObject(, "PowerPoint.Application")
If Err.Number 0 Then
Set appPPT = New PowerPoint.Application
End If
On Error GoTo 0
End If

The worst case is when the code uses GetObject to set appPPT, but the NEW
instance that was created by somebody else isexited. In that case, the
TypeName test causes my class to reset appPPT and, so on .. ..


  #99  
Old June 16th, 2005, 03:01 PM
Steve Rindsberg
external usenet poster
 
Posts: n/a
Default

In article , Howard Kaikow wrote:
The following seems to do the deed, where appPPT is a PPT object with scope
of the class, and the following code is included in each procedure that
needs PPT.

appPPT is never Quit nor set = Nothing.

If TypeName(appPPT) "Application" Then
'Get existing instance of PowerPoint; otherwise create a
new one
' Powerpoint is a single instance application
On Error Resume Next
Set appPPT = GetObject(, "PowerPoint.Application")
If Err.Number 0 Then
Set appPPT = New PowerPoint.Application
End If
On Error GoTo 0
End If

The worst case is when the code uses GetObject to set appPPT, but the NEW
instance that was created by somebody else isexited. In that case, the
TypeName test causes my class to reset appPPT and, so on .. ..


And, to be certain I have the pieces in order, when the instance you create
here goes out of scope, PPT quits also, but only if your instance is the only
one?

Pretty neat!


-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================


  #100  
Old June 16th, 2005, 04:09 PM
Howard Kaikow
external usenet poster
 
Posts: n/a
Default

"Steve Rindsberg" wrote in message
...
And, to be certain I have the pieces in order, when the instance you

create
here goes out of scope, PPT quits also, but only if your instance is the

only
one?

Pretty neat!


The PPT process automatically goes away when there are no more VISIBLE uses
of PPT, and when the NEW instance is Quit.

The implication is that if one never Quits PPT, then one does not adversely
affect others, but others can affect your code if they created the NEW
instance.

It appears that Outlook also works this way, tho i've not tested, so it
appears to be the MSFT "standard" for single instance apps.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to put powerpoint inside of powerpoint? (picture in picture?) Jwolfer Powerpoint 5 January 28th, 2005 11:37 PM
Limit Outlook to one single instance Tito General Discussion 1 January 14th, 2005 07:11 PM
PowerPoint Presentation in Word document! Kumar General Discussion 2 May 21st, 2004 01:26 PM
multiple custom spell-check dictionaries with word and powerpoint Steve New Users 1 May 2nd, 2004 10:40 AM
Multiple Charts from single instance of data dvt Charts and Charting 1 September 21st, 2003 01:45 PM


All times are GMT +1. The time now is 01:59 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.