Closing a Ppt presentation that I opened

  • Thread starter christophercbrewster via OfficeKB.com
  • Start date
C

christophercbrewster via OfficeKB.com

I have a routine that gets information from a Powerpoint file. To use Ppt, it
has this at the beginning:

Set ppt = GetObject(, "Powerpoint.Application")
ppt.Visible = True
ppt.presentations.Open "mypresentation.ppt"

But I can't find a way to close it. The obvious one doesn't work: using the
same statement as the last one above, but changing Open to Close. (I also
tried it with the filename deleted.) Any suggestions?

--
Christopher Brewster
Lockheed Martin, Eagan MN

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200810/1
 
H

Helmut Weber

Hi Christopher,

perhaps like that:

Sub Testxxx()
Dim ppt As Object
Set ppt = GetObject(, "Powerpoint.Application")
ppt.Visible = True
ppt.presentations.Open "c:\test\Presentation1.ppt"
ppt.presentations(1).Close
End Sub

or

Sub Testxxx4()
Dim ppt As Object
Set ppt = GetObject(, "Powerpoint.Application")
ppt.Visible = True
ppt.presentations.Open "c:\test\Presentation1.ppt"
ppt.presentations("Presentation1.ppt").Close
End Sub
--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
C

christophercbrewster via OfficeKB.com

Thanks-- it works and makes sense.

Helmut said:
Hi Christopher,

perhaps like that:

Sub Testxxx()
Dim ppt As Object
Set ppt = GetObject(, "Powerpoint.Application")
ppt.Visible = True
ppt.presentations.Open "c:\test\Presentation1.ppt"
ppt.presentations(1).Close
End Sub

or

Sub Testxxx4()
Dim ppt As Object
Set ppt = GetObject(, "Powerpoint.Application")
ppt.Visible = True
ppt.presentations.Open "c:\test\Presentation1.ppt"
ppt.presentations("Presentation1.ppt").Close
End Sub
--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
C

christophercbrewster via OfficeKB.com

If I could ask a related question...

Being able to close the presentation (thanks!) makes me realize that my macro
is unable to open the presentation unless Powerpoint is already open. (I
didn't realize this with my preliminary version.) I'd like to say "If
Powerpoint isn't open, open it", and at the end "If Powerpoint needed to be
opened, close it now". Is there a way to do this?
 
D

Doug Robbins - Word MVP

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top