PDA

View Full Version : Auto Run



countryfan_n
02-22-2009, 06:48 AM
Hello friends,

Can someone please help me. I have a VBA code named "ABC" in a powerpoint presentation. I need the code to run the second the presentation is opened.

You know just like Excel's code Workbook_Open

Your kind help is truly appreciated!
Nawaf

Oorang
02-25-2009, 07:57 AM
http://www.vbaexpress.com/forum/archive/index.php/t-550.html

Cosmo
02-25-2009, 09:19 AM
Just so you know, you should be aware that if you use an Add-In for this (which is, to the best of my knowlege, the only way to automatically run a Macro in PPT), anyone who you want to run this presentation will also need the add-in installed as well. Not a problem if this is a document you are using yourself, but if you have to distribute this document, you will need to distribute the Add-In, and the users will need to install it before using the document. You may run into problems especially in a corporate environment; many will not look too kindly on installing add-ins.

Oorang
02-25-2009, 05:51 PM
Good observation :)

Paul_Hossler
02-25-2009, 06:09 PM
ref #3 in http://www.vbaexpress.com/forum/showthread.php?t=23813

For 2007 --

I've used the CustomUI onRibbonLoad to execute an "auto run" in PP by creating a barebones CustomUI XML in the PP file.

Paul

Cosmo
02-25-2009, 09:24 PM
ref #3 in http://www.vbaexpress.com/forum/showthread.php?t=23813

For 2007 --

I've used the CustomUI onRibbonLoad to execute an "auto run" in PP by creating a barebones CustomUI XML in the PP file.

Paul
I haven't used 2007 much just yet (I end up pulling my hair out trying to figure out how to do simple stuff, I just usually switch back to 2003), so I'm not familiar with this. I'll look into that when I get to work tomorrow, but does that actually work to allow running a macro on opening a document (without my client having to set anything up prior or install any add-ins)? If so, tht would save me a lot of the hassle I've had with some of our presentations. They just upgraded to 2007 within the last month or so (from version 2000, no less) so this is pretty good timing, and might actually get me to spend more time learning 2007 if this actually works.

Paul_Hossler
02-26-2009, 05:53 AM
Since you're also in PA :hi: ....

Try this and see it the concept works for you

Paul

Cosmo
02-26-2009, 08:07 AM
Since you're also in PA :hi: ....

Howdy! :hi:


Try this and see it the concept works for you

Paul
Nice! It worked, dialog popped up on open.

But, when I saved it as a ppsm, the dialog didn't pop up. Can this technique work with a file saved as a show? That's how my programs I create for my client work presently (although this might not be a big deal, I should be able to hide the presentation, and just go right into the UserForm that I start up with.)

Thanks! :)

John Wilson
02-26-2009, 09:55 AM
Cosmo

When you start a show (directly from a ppsm)there's no Ribbon > On Load event so the code to initialise the event handler doesn't run

Cosmo
02-26-2009, 10:55 AM
Cosmo

When you start a show (directly from a ppsm)there's no Ribbon > On Load event so the code to initialise the event handler doesn't run

Ok, thanks. I can't wait to get a chance to look into this further and try it out on my own files. I just wish Microsoft would include the same functionality to auto-run a macro in Powerpoint that they have in their other programs. I can see why it could be considered a security issue, but I don't understand why they would deem it more of an issue for PowerPoint than for Excel, for example.

Thanks again.

Paul_Hossler
02-26-2009, 01:59 PM
But, when I saved it as a ppsm, the dialog didn't pop up. Can this technique work with a file saved as a show?


Hmmmm - have to admit I never tried it that way

No idea about what or what else to try

Sorry

Paul

John Wilson
02-27-2009, 03:40 AM
Maybe use a pptm instead of a ppsm and add this line of code to the Initialise event in Class Modules

ActivePresentation.SlideShowSettings.Run

Paul_Hossler
02-27-2009, 08:27 AM
I'll go with John on this -- Anybody who has his own web site can't be wrong
:thumb


I tried this in the pptm Ribbon Load callback, and it "works", but not as cleanly as I'd like

I didn't have a way to automatically .Quit the presentation or PP



'Callback for customUI.onLoad
Sub onLoad()
Set cPPTObject.PPTEvent = Application
ActivePresentation.SlideShowSettings.Run
End Sub



Paul