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. |
|
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|