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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Is Powerpoint still a single instance app?
As of Powerpoint 2000, it is my understanding that there can only be a
single instance of Powerpoint running. Is that still true for Powerpoint 2002 and 2003? I've been using code such as the following: '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 blnNewPPT = False Else Set appPPT = New PowerPoint.Application blnNewPPT = True End If On Error GoTo 0 and then With appPPT If blnNewPPT Then .Quit Else .ActivePresentation.Close End If End With However, I suspect that code may not be good enough. Do I not need to know whether the single instance of Powerpoint is being used by another user, even if I created the instance within the code? -- http://www.standards.com/; See Howard Kaikow's web site. |
#2
|
|||
|
|||
In article , Howard Kaikow wrote:
As of Powerpoint 2000, it is my understanding that there can only be a single instance of Powerpoint running. Is that still true for Powerpoint 2002 and 2003? Still true. All versions from 97 on are devoutly single-instance. A few things that might help distinguish between a session you invoked from scratch and a reference to an existing session: With app.PPT if .Presentations.Count = 1 Then if .Presentations(1).Path = "" and _ .Presentations(1).Name = "Presentation1" Then ' it's your session or ' somebody started PPT but hasn't done anything yet End If End if End With I've been using code such as the following: '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 blnNewPPT = False Else Set appPPT = New PowerPoint.Application blnNewPPT = True End If On Error GoTo 0 and then With appPPT If blnNewPPT Then .Quit Else .ActivePresentation.Close End If End With However, I suspect that code may not be good enough. Do I not need to know whether the single instance of Powerpoint is being used by another user, even if I created the instance within the code? ----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================ |
#3
|
|||
|
|||
"Steve Rindsberg" wrote in message
... Still true. All versions from 97 on are devoutly single-instance. Should "devoutly" be "devilishly"? A few things that might help distinguish between a session you invoked from scratch and a reference to an existing session: With app.PPT if .Presentations.Count = 1 Then if .Presentations(1).Path = "" and _ .Presentations(1).Name = "Presentation1" Then ' it's your session or ' somebody started PPT but hasn't done anything yet End If End if End With Ayup, I thought about those, but the real issue is control. If I decide that I own the session and nobody else is using powerpoint, there is still an instant or so, during which I'd be killing the critter and somebdy might have just started a session. I run only in a single user environment, so I cannot test some concerns? Is the single instance of PowerPoint system wide, or is it on a desktop by desktop basis, on a multi-user system? If the latter, I could disable the desktop whilst I kill the critter. |
#4
|
|||
|
|||
In article , Howard Kaikow wrote:
"Steve Rindsberg" wrote in message ... Still true. All versions from 97 on are devoutly single-instance. Should "devoutly" be "devilishly"? g That depends on whether you want to have multiple instances or to be certain of which instance you have. ;-) A few things that might help distinguish between a session you invoked from scratch and a reference to an existing session: With app.PPT if .Presentations.Count = 1 Then if .Presentations(1).Path = "" and _ .Presentations(1).Name = "Presentation1" Then ' it's your session or ' somebody started PPT but hasn't done anything yet End If End if End With Ayup, I thought about those, but the real issue is control. If I decide that I own the session and nobody else is using powerpoint, there is still an instant or so, during which I'd be killing the critter and somebdy might have just started a session. Point taken, and it'd be better to head that off at the pass if possible. Still, in that case the worst that'd happen is that the new session wouldn't start. I can't tell you how often I'm sure I doubleclicked something but got no reaction, oh well, try again. Wouldn't this appear to be one of those? In other words, it might be very mildly puzzling, surely far less than normal Windows behavior can be, but wouldn't cause any loss of data. I run only in a single user environment, so I cannot test some concerns? Is the single instance of PowerPoint system wide, or is it on a desktop by desktop basis, on a multi-user system? If the latter, I could disable the desktop whilst I kill the critter. It would almost have to be on a desktop by desktop basis, else PowerPoint would be stumbling all over itself whenever two users had it active. Same would be true of any app I'd think. Not so much true of the app, in fact, but a question of whether Windows permits them to see one another. It'd have to be keeping them all (and each user's session) in separate memory spaces wouldn't it? To be sure, that's speculation on my part. ----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================ |
#5
|
|||
|
|||
"Steve Rindsberg" wrote in message
... That depends on whether you want to have multiple instances or to be certain of which instance you have. ;-) The goal is to automate powerpoint from word in an a vb 6 program. once the task is done, there's no need to retain the powerpoint instance, not unlike a multi-use app, i.e., it's bad to allow instances of multi-use apps to be left active. Point taken, and it'd be better to head that off at the pass if possible. Still, in that case the worst that'd happen is that the new session wouldn't start. I can't tell you how often I'm sure I doubleclicked something but got no reaction, oh well, try again. Wouldn't this appear to be one of those? In other words, it might be very mildly puzzling, surely far less than normal Windows behavior can be, but wouldn't cause any loss of data. I guess the best I can do, is lock the desktop momentarily, and check the Presentations count. If = 1, then I'd quit powerpoint, otherwise, I'd let it live and be visible. Of course, visibility is another issue. If I created the instance with GetObject, instead of NEW, I'd have to take care not to make powerpoint invisible if some else is udsing the critter. It would almost have to be on a desktop by desktop basis, else PowerPoint would be stumbling all over itself whenever two users had it active. Same would be true of any app I'd think. Not so much true of the app, in fact, but a question of whether Windows permits them to see one another. It'd have to be keeping them all (and each user's session) in separate memory spaces wouldn't it? That's what I would think. I'll code as if that were true, i.e., lock the desktop while using a NEW powerpoint instance. |
#6
|
|||
|
|||
It has ben suggested that id, instead og killing the powerpoint instance, if
i just set it to Nothing, the instance of powerpoint will go away if there are no other powerpoint sessions. I'll try this later. I would feel comfortable relying on this only if I saw documentation of this behavior, and for powerpont 97, 2000, 2002 and 2003. |
#7
|
|||
|
|||
Came up with a "solution".
Seems too simple to be correct. For the code below, one needs a Userform with 3 buttons. 1. Shut down any running PowerPoint. 2. Click on the Create PPT button. 3. After the program creates a PPT session, create a PPT session via the GUI, not using the icon minimized by the code. 4. Click on the Close PPT button. 5. Click on the Bye Bye button. This code would appear to work for those cases in which my code need not keep a presentation alive. So, if I close all the code's presentations, this method appears to work. If I have to keep a presentation alive, that should be no problem as I just would not close PowerPoint, just set its object variable = Nothing. Does this hanky panky solve the problem? Option Explicit Private appPPT As Powerpoint.Application Private blnNewPPT As Boolean ' Private MyPrivateName As String Private Sub btnByeBye_Click() Unload Me End Sub Private Sub btnClosePPT_Click() With appPPT If blnNewPPT Then If .Presentations.Count = 0 Then .Quit lstActions.AddItem "New instance was Quit." Else lstActions.AddItem "New instance was NOT Quit." End If Else On Error Resume Next .ActivePresentation.Close On Error GoTo 0 lstActions.AddItem "Extant instance was not Quit." End If End With Set appPPT = Nothing lstActions.AddItem "Set instance = Nothing." On Error Resume Next lstActions.AddItem Err.Number & ":" & Err.Description On Error GoTo 0 End Sub Private Sub btnCreatePPT_Click() 'Get existing instance of PowerPoint; otherwise create a new one On Error Resume Next Set appPPT = GetObject(, "PowerPoint.Application") lstActions.AddItem Err.Number & ":" & Err.Description If Err.Number = 0 Then blnNewPPT = False lstActions.AddItem "Extant instance is being used." Else Set appPPT = New Powerpoint.Application blnNewPPT = True lstActions.AddItem "New instance was created." End If With appPPT ' MyPrivateName = "HK" & Now & CDbl(Now) .Visible = True .WindowState = ppWindowMinimized lstActions.AddItem "Presentations Count: " & .Presentations.Count End With On Error GoTo 0 End Sub |
#8
|
|||
|
|||
The "solution" does not detect a Powerpoint session that has no
presentations, other than my own. Is there an API, or some such that can tell me a reference count, or whatever, number of PowerPoint instances being used? P.S.: I've been using the wrong terminology. MSFT uses "multi-use" and I've been using "single use". -- http://www.standards.com/; See Howard Kaikow's web site. "Howard Kaikow" wrote in message ... Came up with a "solution". Seems too simple to be correct. For the code below, one needs a Userform with 3 buttons. 1. Shut down any running PowerPoint. 2. Click on the Create PPT button. 3. After the program creates a PPT session, create a PPT session via the GUI, not using the icon minimized by the code. 4. Click on the Close PPT button. 5. Click on the Bye Bye button. This code would appear to work for those cases in which my code need not keep a presentation alive. So, if I close all the code's presentations, this method appears to work. If I have to keep a presentation alive, that should be no problem as I just would not close PowerPoint, just set its object variable = Nothing. Does this hanky panky solve the problem? Option Explicit Private appPPT As Powerpoint.Application Private blnNewPPT As Boolean ' Private MyPrivateName As String Private Sub btnByeBye_Click() Unload Me End Sub Private Sub btnClosePPT_Click() With appPPT If blnNewPPT Then If .Presentations.Count = 0 Then .Quit lstActions.AddItem "New instance was Quit." Else lstActions.AddItem "New instance was NOT Quit." End If Else On Error Resume Next .ActivePresentation.Close On Error GoTo 0 lstActions.AddItem "Extant instance was not Quit." End If End With Set appPPT = Nothing lstActions.AddItem "Set instance = Nothing." On Error Resume Next lstActions.AddItem Err.Number & ":" & Err.Description On Error GoTo 0 End Sub Private Sub btnCreatePPT_Click() 'Get existing instance of PowerPoint; otherwise create a new one On Error Resume Next Set appPPT = GetObject(, "PowerPoint.Application") lstActions.AddItem Err.Number & ":" & Err.Description If Err.Number = 0 Then blnNewPPT = False lstActions.AddItem "Extant instance is being used." Else Set appPPT = New Powerpoint.Application blnNewPPT = True lstActions.AddItem "New instance was created." End If With appPPT ' MyPrivateName = "HK" & Now & CDbl(Now) .Visible = True .WindowState = ppWindowMinimized lstActions.AddItem "Presentations Count: " & .Presentations.Count End With On Error GoTo 0 End Sub |
#9
|
|||
|
|||
i stumbled upon a possible solution last night.
i'll try to verify later today or tonight. -- http://www.standards.com/; See Howard Kaikow's web site. "Howard Kaikow" wrote in message ... The "solution" does not detect a Powerpoint session that has no presentations, other than my own. Is there an API, or some such that can tell me a reference count, or whatever, number of PowerPoint instances being used? P.S.: I've been using the wrong terminology. MSFT uses "multi-use" and I've been using "single use". -- http://www.standards.com/; See Howard Kaikow's web site. "Howard Kaikow" wrote in message ... Came up with a "solution". Seems too simple to be correct. For the code below, one needs a Userform with 3 buttons. 1. Shut down any running PowerPoint. 2. Click on the Create PPT button. 3. After the program creates a PPT session, create a PPT session via the GUI, not using the icon minimized by the code. 4. Click on the Close PPT button. 5. Click on the Bye Bye button. This code would appear to work for those cases in which my code need not keep a presentation alive. So, if I close all the code's presentations, this method appears to work. If I have to keep a presentation alive, that should be no problem as I just would not close PowerPoint, just set its object variable = Nothing. Does this hanky panky solve the problem? Option Explicit Private appPPT As Powerpoint.Application Private blnNewPPT As Boolean ' Private MyPrivateName As String Private Sub btnByeBye_Click() Unload Me End Sub Private Sub btnClosePPT_Click() With appPPT If blnNewPPT Then If .Presentations.Count = 0 Then .Quit lstActions.AddItem "New instance was Quit." Else lstActions.AddItem "New instance was NOT Quit." End If Else On Error Resume Next .ActivePresentation.Close On Error GoTo 0 lstActions.AddItem "Extant instance was not Quit." End If End With Set appPPT = Nothing lstActions.AddItem "Set instance = Nothing." On Error Resume Next lstActions.AddItem Err.Number & ":" & Err.Description On Error GoTo 0 End Sub Private Sub btnCreatePPT_Click() 'Get existing instance of PowerPoint; otherwise create a new one On Error Resume Next Set appPPT = GetObject(, "PowerPoint.Application") lstActions.AddItem Err.Number & ":" & Err.Description If Err.Number = 0 Then blnNewPPT = False lstActions.AddItem "Extant instance is being used." Else Set appPPT = New Powerpoint.Application blnNewPPT = True lstActions.AddItem "New instance was created." End If With appPPT ' MyPrivateName = "HK" & Now & CDbl(Now) .Visible = True .WindowState = ppWindowMinimized lstActions.AddItem "Presentations Count: " & ..Presentations.Count End With On Error GoTo 0 End Sub |
#10
|
|||
|
|||
I guess the best I can do, is lock the desktop momentarily, and check the
Presentations count. If = 1, then I'd quit powerpoint, otherwise, I'd let it live and be visible. Depending on user settings and version, PPT may automatically create a blank presentation on startup, so presentation count might be 0 or 1 even if you've invoked it. That's why I suggested the other rigamarole re checking the presentation's name (always Presentation1 until it's been saved) and the path (blank until it's been saved). |
Thread Tools | |
Display Modes | |
|
|
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 |