A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Powerpoint, Publisher and Visio » Powerpoint
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

close application from event handler



 
 
Thread Tools Display Modes
  #1  
Old July 14th, 2008, 03:21 PM posted to microsoft.public.powerpoint
theintern
external usenet poster
 
Posts: 58
Default close application from event handler

I'd like to close PowerPoint from an event handler, but it gives me an error
when i try to do so. Right now i have it set up so that when PP is open a
macro runs the show for a set amount of time. At the end of that, the show
is closed (ActivePresentation.close) and then i'd like PP to close as well
(Application.quit) but apparently this code can't be run off an event. Any
ideas?

thanks
scott
  #2  
Old July 14th, 2008, 03:37 PM posted to microsoft.public.powerpoint
theintern
external usenet poster
 
Posts: 58
Default close application from event handler

fyi, the reason i need the application to close is so that the macro will
auto run again the next time the application is open. i.e. the macro won't
auto run if the presentation is re-opened, but PowerPoint was never closed
(because the add-in wasn't reloaded).

"theintern" wrote:

I'd like to close PowerPoint from an event handler, but it gives me an error
when i try to do so. Right now i have it set up so that when PP is open a
macro runs the show for a set amount of time. At the end of that, the show
is closed (ActivePresentation.close) and then i'd like PP to close as well
(Application.quit) but apparently this code can't be run off an event. Any
ideas?

thanks
scott

  #3  
Old July 14th, 2008, 04:33 PM posted to microsoft.public.powerpoint
Chirag
external usenet poster
 
Posts: 595
Default close application from event handler

Looks like you actually need to write event handler code for
PresentationOpen event. PresentationOpen() application event is fired by
PowerPoint whenever an existing presentation is opened.

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html

"theintern" wrote in message
...
fyi, the reason i need the application to close is so that the macro will
auto run again the next time the application is open. i.e. the macro
won't
auto run if the presentation is re-opened, but PowerPoint was never closed
(because the add-in wasn't reloaded).

"theintern" wrote:

I'd like to close PowerPoint from an event handler, but it gives me an
error
when i try to do so. Right now i have it set up so that when PP is open
a
macro runs the show for a set amount of time. At the end of that, the
show
is closed (ActivePresentation.close) and then i'd like PP to close as
well
(Application.quit) but apparently this code can't be run off an event.
Any
ideas?

thanks
scott


  #4  
Old July 14th, 2008, 07:07 PM posted to microsoft.public.powerpoint
theintern
external usenet poster
 
Posts: 58
Default close application from event handler

thanks for getting back to me.

Right now i have it firing on "AfterPresentationOpen", and the command
'ActivePresentation.close' works fine. However, with this command, the macro
isn't fired each time my presenation is opened (because PowerPoint never
closes i guess?). But if i try and switch it to PresentationOpen, then the
command 'ActivePresentation.close' doesn't work anymore. It tells me I can't
call that from an event handler. Seems like something isn't working the way
it should...thoughts?

thanks
scott

"Chirag" wrote:

Looks like you actually need to write event handler code for
PresentationOpen event. PresentationOpen() application event is fired by
PowerPoint whenever an existing presentation is opened.

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html

"theintern" wrote in message
...
fyi, the reason i need the application to close is so that the macro will
auto run again the next time the application is open. i.e. the macro
won't
auto run if the presentation is re-opened, but PowerPoint was never closed
(because the add-in wasn't reloaded).

"theintern" wrote:

I'd like to close PowerPoint from an event handler, but it gives me an
error
when i try to do so. Right now i have it set up so that when PP is open
a
macro runs the show for a set amount of time. At the end of that, the
show
is closed (ActivePresentation.close) and then i'd like PP to close as
well
(Application.quit) but apparently this code can't be run off an event.
Any
ideas?

thanks
scott


  #5  
Old July 14th, 2008, 07:26 PM posted to microsoft.public.powerpoint
theintern
external usenet poster
 
Posts: 58
Default close application from event handler

Yeah, neither PresentationOpen nor AfterPresentationOpen fire except for the
first time. To fire again, powerpoint has to be completely closed and then
reopened. Is there a way to get them to fire everytime a presenation is
opened (even if PP is already open) and/or close powerpoint completely (it
doesn't like using Application.close from an event handler.)

thanks
scott

"Chirag" wrote:

Looks like you actually need to write event handler code for
PresentationOpen event. PresentationOpen() application event is fired by
PowerPoint whenever an existing presentation is opened.

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html

"theintern" wrote in message
...
fyi, the reason i need the application to close is so that the macro will
auto run again the next time the application is open. i.e. the macro
won't
auto run if the presentation is re-opened, but PowerPoint was never closed
(because the add-in wasn't reloaded).

"theintern" wrote:

I'd like to close PowerPoint from an event handler, but it gives me an
error
when i try to do so. Right now i have it set up so that when PP is open
a
macro runs the show for a set amount of time. At the end of that, the
show
is closed (ActivePresentation.close) and then i'd like PP to close as
well
(Application.quit) but apparently this code can't be run off an event.
Any
ideas?

thanks
scott


  #6  
Old July 14th, 2008, 08:18 PM posted to microsoft.public.powerpoint
Steve Rindsberg
external usenet poster
 
Posts: 9,366
Default close application from event handler

In article , Theintern
wrote:
I'd like to close PowerPoint from an event handler, but it gives me an error
when i try to do so. Right now i have it set up so that when PP is open a
macro runs the show for a set amount of time. At the end of that, the show
is closed (ActivePresentation.close) and then i'd like PP to close as well
(Application.quit) but apparently this code can't be run off an event. Any
ideas?


What's the exact error message you get.

And have you tried firing a sub in your addin from within the event handler
class:

ByeBye

Public Sub ByeBye()
Application.Quit
End Sub

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================


  #7  
Old July 14th, 2008, 08:33 PM posted to microsoft.public.powerpoint
theintern
external usenet poster
 
Posts: 58
Default close application from event handler

putting it in the add-in didn't work. no error message, but it didn't close
anything. basically it was like it ignored the code. here is how i had it.

Public WithEvents PPTEvent As Application

Private Sub PPTEvent_PresentationOpen(ByVal Pres As Presentation)
CreateShow
End Sub

Public Sub ByeBye()
Application.Quit
End Sub

As far as the error...if i try and use "application.quit" with
"PresentationOpen" i get:

Run-time error "-2147188160(80048240)":
Application(unknown member): Invalid request. This operation cannot be
performed in this event handler.

thanks for helping me with this.
scott

"Steve Rindsberg" wrote:

In article , Theintern
wrote:
I'd like to close PowerPoint from an event handler, but it gives me an error
when i try to do so. Right now i have it set up so that when PP is open a
macro runs the show for a set amount of time. At the end of that, the show
is closed (ActivePresentation.close) and then i'd like PP to close as well
(Application.quit) but apparently this code can't be run off an event. Any
ideas?


What's the exact error message you get.

And have you tried firing a sub in your addin from within the event handler
class:

ByeBye

Public Sub ByeBye()
Application.Quit
End Sub

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================



  #8  
Old July 14th, 2008, 08:41 PM posted to microsoft.public.powerpoint
theintern
external usenet poster
 
Posts: 58
Default close application from event handler

I tried the following as well. Same error message as other strategy.

Public WithEvents PPTEvent As Application

Private Sub PPTEvent_PresentationOpen(ByVal Pres As Presentation)
CreateShow
ByeBye
End Sub

Public Sub ByeBye()
Application.Quit
End Sub


"Steve Rindsberg" wrote:

In article , Theintern
wrote:
I'd like to close PowerPoint from an event handler, but it gives me an error
when i try to do so. Right now i have it set up so that when PP is open a
macro runs the show for a set amount of time. At the end of that, the show
is closed (ActivePresentation.close) and then i'd like PP to close as well
(Application.quit) but apparently this code can't be run off an event. Any
ideas?


What's the exact error message you get.

And have you tried firing a sub in your addin from within the event handler
class:

ByeBye

Public Sub ByeBye()
Application.Quit
End Sub

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================



  #9  
Old July 16th, 2008, 03:52 PM posted to microsoft.public.powerpoint
Steve Rindsberg
external usenet poster
 
Posts: 9,366
Default close application from event handler

I'm not clear on what you put where ...

I'm thinking you need an addin project with at least one regular basic module and
one class.

The bas module contains your CreateShow code and the "byebye" sub, plus whatever
other code you need.

The class contains just the event handler code. The PresentationOpen event should
call your CreateShow code and the end show event should call ByeBye.

See how that works ...

In article , Theintern wrote:
I tried the following as well. Same error message as other strategy.

Public WithEvents PPTEvent As Application

Private Sub PPTEvent_PresentationOpen(ByVal Pres As Presentation)
CreateShow
ByeBye
End Sub

Public Sub ByeBye()
Application.Quit
End Sub

"Steve Rindsberg" wrote:

In article , Theintern
wrote:
I'd like to close PowerPoint from an event handler, but it gives me an error
when i try to do so. Right now i have it set up so that when PP is open a
macro runs the show for a set amount of time. At the end of that, the show
is closed (ActivePresentation.close) and then i'd like PP to close as well
(Application.quit) but apparently this code can't be run off an event. Any
ideas?


What's the exact error message you get.

And have you tried firing a sub in your addin from within the event handler
class:

ByeBye

Public Sub ByeBye()
Application.Quit
End Sub

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================





-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================


  #10  
Old July 16th, 2008, 04:12 PM posted to microsoft.public.powerpoint
theintern
external usenet poster
 
Posts: 58
Default close application from event handler

no go. same error as before, can't call this from an event handler. so
here's how i have it set up:
i have 2 modules, and 1 class

the first module is called AutoRun:
Public cPPTObject As New EventClass

Sub Auto_Open()
'set an application reference to the event-enabled object
Set cPPTObject.PPTEvent = Application
End Sub

the second module is called CreateShowmod:
sub CreateShow()
a bunch of code...
end sub
sub byebye
application.quit
end sub

the class is called EventClass:
Public WithEvents PPTEvent As Application

Private Sub PPTEvent_PresentationOpen(ByVal Pres As Presentation)
CreateShow
End Sub

it just really doesn't want me to call application.quit from an event
handler. if only afterpresentationopen would fire every time, even if PP
wasn't fully closed...
i'm trying to figure out some other ways around this as well, seeing if it
will let me call application.quit from a different event. this is so
frustrating.

thanks
scott

"Steve Rindsberg" wrote:

I'm not clear on what you put where ...

I'm thinking you need an addin project with at least one regular basic module and
one class.

The bas module contains your CreateShow code and the "byebye" sub, plus whatever
other code you need.

The class contains just the event handler code. The PresentationOpen event should
call your CreateShow code and the end show event should call ByeBye.

See how that works ...

In article , Theintern wrote:
I tried the following as well. Same error message as other strategy.

Public WithEvents PPTEvent As Application

Private Sub PPTEvent_PresentationOpen(ByVal Pres As Presentation)
CreateShow
ByeBye
End Sub

Public Sub ByeBye()
Application.Quit
End Sub

"Steve Rindsberg" wrote:

In article , Theintern
wrote:
I'd like to close PowerPoint from an event handler, but it gives me an error
when i try to do so. Right now i have it set up so that when PP is open a
macro runs the show for a set amount of time. At the end of that, the show
is closed (ActivePresentation.close) and then i'd like PP to close as well
(Application.quit) but apparently this code can't be run off an event. Any
ideas?

What's the exact error message you get.

And have you tried firing a sub in your addin from within the event handler
class:

ByeBye

Public Sub ByeBye()
Application.Quit
End Sub

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================





-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:54 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.