Avatar of SweetingA
SweetingA asked on

Close named powerpoint presentation in vba

I have two powerpoint presenatations open.

I want to close only one of them.

I used application.quit but it closed all as it closes powerpoint.

I therefore used Application.ActivePresentation.Close which works but leaves the window open so i can't see my other ppt presenatation below.

All help most welcome.
Microsoft PowerPointMicrosoft DevelopmentMicrosoft Applications

Avatar of undefined
Last Comment
SweetingA

8/22/2022 - Mon
John Wilson

Not completely clear what you need but supposing you want to close the presentation named "control.pptx" and minimize PPt

Presentations("control.pptx").Close
Application.WindowState = ppWindowMinimized
Rgonzo1971

Hi,

pls try

'Application.Presentations("c:\Documents\Presentation4.pptx").Close or
Application.ActivePresentation.Close
Application.ActiveWindow.Activate

Open in new window

Regards
John Wilson

I misread!

You really need to say what version of Office as versions before 2010 act differently

In all cases though the other presentaion should show I think unless you are running the code from the vb editor.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER
SweetingA

I am using ppt2010
ASKER
SweetingA

JSRWilson, your solution did not work as window is not minimised
ASKER
SweetingA

Rgonzo1971, same as JRWilson, closes presentation show but does not close or minimise active window
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
SweetingA

What i am doing is running several ppsm presentations from a common dashboard and i intended to leave the dashboard open and just bring the ppsm's to the front and close them on exit.

It works fine except the ppsm window stays on the screen with the dashboard hidden behind it.
John Wilson

You need to explain exactly what you are doing. Starting with how you made the Dashboared and what it does. Are the ppsm opening in show mode and how are you opening and closing them.
ASKER
SweetingA

The dashboard is just a page of buttons, i run it from a batch file at startup, its a ppsm file

Under each button is a simple code see attached to run various presnetations

Me.CommandButton7.Caption = "Introducing" & vbNewLine & "GMP"
Me.CommandButton7.Font.Size = 10

Dim pptPres As PowerPoint.Presentation
Dim pptApp As PowerPoint.Application
Dim pptSlide As PowerPoint.Slide
Dim file As String

file = "f:\Users\Training\GMPRefresher.ppsm"

Set pptApp = CreateObject("PowerPoint.Application")
pptApp.Visible = True
Set pptPres = pptApp.Presentations.Open(FileName:=file)

At the end of any presenatation, i instruct the user to press a button which should close the current presnetation and window so that the dashboard returns to the screen.

At the moment the presenation closes, but an instance of powerpoint remains open so i can see the development window in front of the dashboard.

If i use application.quit it closes all instances of ppt so i loose the dahsboard completely.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Rgonzo1971

Hi,

Have you tried

Set pptApp = Nothing

Open in new window


Regards
ASKER CERTIFIED SOLUTION
John Wilson

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
SweetingA

JSR Wilson - You are a genius. thank you very much