Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Sep 2006
    Location
    New York, New York, USA
    Posts
    76
    Thanks
    1
    Thanked 0 Times in 0 Posts

    PPT 2010: VBA Quit Method Closes ALL PPT Instances

    I have a VB6 app that automates different Office applications. I need to be able to create different instances of these apps at various times, some "hidden" in order to interrogate various metadata, for example, version of the Office app installed on client machine, among other things.

    I noticed that invoking the PPT VBA "Quit" method does not close just the PPT instance associated with the application object that it is invoked for, it also closes all other PPT instances that are open at the time the method is invoked. This is unlike other Office apps, like Word, which terminate only the associated instance.

    I am attaching some sample code. Please note that I create the Office objects late-bound because different users will have different versions of Office installed (hence the interrogation of version mentioned above).

    VB6 app:

    Create a new form and place the following code in the Form_Load() event:

    Code:
    Private Sub Form_Load()
    Dim ppt As Object
    Set ppt = CreateObject("PowerPoint.Application")
    ppt.Visible = True
    ppt.quit
    Set ppt = Nothing
    End Sub
    Start PowerPoint manually (e.g. not through VB automation), then run the above code. You will see that the automated instance opens and closes, AND the instance started manually closes as well. CreateObject should be getting a unique handle to a unique instance of PPT.

    Any ideas?

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Since I don't have VB6 I can't test this theory but have you tried it w/o the ppt.quit statement? Setting ppt to nothing should destroy the instance although I don't know if it will have an effect on the manually opened instance.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    Star Lounger
    Join Date
    Sep 2006
    Location
    New York, New York, USA
    Posts
    76
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi RG, thanks for the quick response. Yes, I did try that and is actually what I decided on as my solution. In fact, PPT does not show up in Task Manager as a separately-running instance when automated if there is an instance already running! This is what lead to my conclusion that it always runs as a single instance (or, process) -- hence my reference to SDI (Single-Document Interface) and MDI (Multiple-Document Interface). It would also explain why using Quit caused the other "instance" to close as well.

    But this doesn't make sense to me unless PPT is different from other Office apps -- at least, Word -- in how it is instantiated.

  4. #4
    3 Star Lounger
    Join Date
    Feb 2007
    Location
    Durham, Durham, United Kingdom
    Posts
    286
    Thanks
    0
    Thanked 10 Times in 10 Posts
    PowerPoint 2010 is SDI not multiple instance.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •