How to close an active presentation that is open in MS PowerPoint in VB.net

Ruby Sharma 1 Reputation point
2022-10-03T11:34:29.503+00:00

We have designed Microsoft Addins for MS PowerPoint 2019 written in VB.net. There we have taken a counter (pptCounter) which increases whenever a presentation (either existing or new) opens. So we want to delete this open presentation after the counter becomes more than 1.But it didn't close the open file.

We have used this below given snippet :

Private Sub WorkWithDocument(ByVal Doc As Microsoft.Office.Interop.PowerPoint.Presentation) Handles Application.PresentationOpen

If (pptCounter > 1) Then

Globals.Connect.Application.ActivePresentation.Close()

End If

End Sub Here is some more information about which environment I'm working in:

Operating System : Microsoft Windows 10 Pro

Code Editor : Visual Studio 2019

Technology : Vb.net(.Net Framewor

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,489 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Oskar Shon 866 Reputation points MVP
    2022-11-09T11:13:37.773+00:00

    You named Doc like inside parametr your procedure.
    Try to close it or set it to global variable as object collection to do something with it
    or if you have multiple PP open and you want to close it all, then find handles of PP application and close it.

    Regards

    0 comments No comments

  2. Oskar Shon 866 Reputation points MVP
    2022-11-09T11:13:38.607+00:00

    You named Doc like inside parametr your procedure.
    Try to close it or set it to global variable as object collection to do something with it
    or if you have multiple PP open and you want to close it all, then find handles of PP application and close it.

    Regards

    0 comments No comments