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 |
#11
|
|||
|
|||
Howard, What about iterating through the current window collection before attempting to get a PPT object; if any of the windows belong to PowerPoint, then somebody's using it. PowerPoint 11 (2003) down to PPT97: "PP11FrameClass" "PP10FrameClass" "PP9FrameClass" "PP97FrameClass" ----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================ |
#12
|
|||
|
|||
http://www.standards.com/; See Howard Kaikow's web site.
"Steve Rindsberg" wrote in message ... 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). Yes, I realize that, and there may even be no presentation. That's why I'm trying the following. ------------------------- I've come up with the following, is it valid? 1. Make sure that PowerPoint is not running. 2. Run a VB 6 program that creates a NEW instance of PowerPoint. 3. While the program in step 2 is still running, and PPT has not been Quit, run another VB 6 program that enumerates desktop processes, call the output List 1. 4. While the PPT from step 2 is still running, start PowerPoint from the desktop. Since I had already created an instance in step 2, both should end up using the same instance as PowerPoint is multi-use, single instance. 5. Now, again run the program that enumerates desktop processes, call the output List 2. Both List 1 and List 2 give the same handle for PowerPoint, and the same number of top level windows, List 1 does not list an active presentation, whilst List 2 lists Presentation1. So the first bit of info is that the PowerPoint window will be that of the latest use of Powerpoint. So this doesn't help solve my problem. However, the Total Thread Windows is 9 for List 1, 11 for List 2 I am enumerating the processes using code based on KB article 183009 and only incrementing the counters when PP11FrameClass is found. So, is it safe to ASSuME that I can determine that there is another user using my PowerPoint object if the thread count is greater than the number reported by List 1? |
#13
|
|||
|
|||
"Steve Rindsberg" wrote in message
... Howard, What about iterating through the current window collection before attempting to get a PPT object; if any of the windows belong to PowerPoint, then somebody's using it. See my posting of a few minutes ago where I enumerated processes. The sticky point is that my New instance of PPT is still open when I do the iterations, i.e., I'm trying to determine whether I can Quit. I am hoping that I can do this based on the thread count, as discussed in my other posting. it is necessary to do this iterating only if the presentation count is 0, as i have already closed my, if any, presentation. |
#14
|
|||
|
|||
Not yet there, the code from the KB article is enumerating Windows, not
processes, so doesn't handle case where presentation count = 0. |
#15
|
|||
|
|||
Appears that I can do the deed by iterating processes.
Needs further testing. |
#16
|
|||
|
|||
See my posting of a few minutes ago where I enumerated processes.
The sticky point is that my New instance of PPT is still open when I do the iterations, i.e., I'm trying to determine whether I can Quit. So the problem at this point is: Having fired off your own instance of PPT, how can you be certain that a user hasn't in the interim invoked PPT on their own? If you know that you started by invoking PPT when it wasn't previously open, then you should also be able to maintain a count of any presentations you've opened or created; if someone manually starts/opens another presentation, then .Presentations.Count will be higher than your total, so it wouldn't be safe to force PPT to quit. Does that oonch us a bit closer? ;-) I am hoping that I can do this based on the thread count, as discussed in my other posting. it is necessary to do this iterating only if the presentation count is 0, as i have already closed my, if any, presentation. ----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================ |
#17
|
|||
|
|||
"Steve Rindsberg" wrote in message
... Having fired off your own instance of PPT, how can you be certain that a user hasn't in the interim invoked PPT on their own? If you know that you started by invoking PPT when it wasn't previously open, then you should also be able to maintain a count of any presentations you've opened or created; if someone manually starts/opens another presentation, then Presentations.Count will be higher than your total, so it wouldn't be safe to force PPT to quit. Does that oonch us a bit closer? ;-) No. Because the presentation count could still be 0. Enumerating processes appears to resolve the problem, but I want to simplify the code. |
#18
|
|||
|
|||
In article , Howard Kaikow wrote:
"Steve Rindsberg" wrote in message ... Having fired off your own instance of PPT, how can you be certain that a user hasn't in the interim invoked PPT on their own? If you know that you started by invoking PPT when it wasn't previously open, then you should also be able to maintain a count of any presentations you've opened or created; if someone manually starts/opens another presentation, then Presentations.Count will be higher than your total, so it wouldn't be safe to force PPT to quit. Does that oonch us a bit closer? ;-) No. Because the presentation count could still be 0. Possibly for that instant, but closing an instance of PPT with no open presentations will do no harm. Enumerating processes appears to resolve the problem, but I want to simplify the code. ----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================ |
#19
|
|||
|
|||
"Steve Rindsberg" wrote in message
... Possibly for that instant, but closing an instance of PPT with no open presentations will do no harm. It sure does. It closes the other uses of PPT. Users, and other code, whould not be very ubhappy if theirPPT suddenly disappeared. To restate the problem. ---------------------------- I was using the wrong terminology. PowerPoint is a Multi-use, single Instance app. Assume that PPT is not running. Then my code creates a NEW instance of PPT. Then, while my code is running, PPT is again started by a user from the desktop or via another piece of code. Etc. AFAIK, it is possible for all uses of PPT to have, at any point in time, a Presentations.Count of 0, so I cannot tell whether I should Quit my instance of PPT, based on Presentation count, lest it affect the other uses. At some point, I would do the following: 1. DoEvents 2. Disable keyboard and mouse input 3. test for number of PowerPoint critters. 4. If only 1 critter, Quit PPT, otherwise let it live. 5. Enable keyboard and mouse input 6. exit from my code. Enumerating processes, using say, the example at ALLAPI, lists a different working set size for each use of PPT. In my case, all I need to know is whether there is one use or more, does not matter how many. If 1 use, then I can safely Quit my instance of Powerpoint. I need to study the ALLAPI, and other examples, to make sure the info is what I need. |
#20
|
|||
|
|||
My app has been doing what Steve suggests for almost 4 years without any
reports of problems. There is one and only one instance of Powerpoint (powerpnt.exe) running regardless of how many programs have a reference count to it or if a user opened the GUI for Powerpoint. I check to make sure that presentations count = 0 then I call the Powerpoint quit method. If a user has started the GUI and closed the pres1 (or whatever) default presentation Powerpoint creates then indeed when you quit PowerPoint it closes the GUI. If other programs have connected to that instance of Powerpoint then they would get an exception when they referenced that object. But that is why there is a big disclaimer on the MS web site that tells us not to use Powerpoint in an automated fashion. We are pretty much out there on our own. I had originally hoped they would expose the reference count through a method or property but I didn't see it. Good luck. "Howard Kaikow" wrote in message ... "Steve Rindsberg" wrote in message ... Possibly for that instant, but closing an instance of PPT with no open presentations will do no harm. It sure does. It closes the other uses of PPT. Users, and other code, whould not be very ubhappy if theirPPT suddenly disappeared. To restate the problem. ---------------------------- I was using the wrong terminology. PowerPoint is a Multi-use, single Instance app. Assume that PPT is not running. Then my code creates a NEW instance of PPT. Then, while my code is running, PPT is again started by a user from the desktop or via another piece of code. Etc. AFAIK, it is possible for all uses of PPT to have, at any point in time, a Presentations.Count of 0, so I cannot tell whether I should Quit my instance of PPT, based on Presentation count, lest it affect the other uses. At some point, I would do the following: 1. DoEvents 2. Disable keyboard and mouse input 3. test for number of PowerPoint critters. 4. If only 1 critter, Quit PPT, otherwise let it live. 5. Enable keyboard and mouse input 6. exit from my code. Enumerating processes, using say, the example at ALLAPI, lists a different working set size for each use of PPT. In my case, all I need to know is whether there is one use or more, does not matter how many. If 1 use, then I can safely Quit my instance of Powerpoint. I need to study the ALLAPI, and other examples, to make sure the info is what I need. |
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 |