We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

PowerPoint 2003 macro to auto run .exe file

mdmcq5
mdmcq5 asked
on
Medium Priority
804 Views
Last Modified: 2012-05-05
I have a PowerPoint presentation and on one of the slides I have a button to play an .exe file, I have located in the same folder.  When I click to play the file the usual warning message pops up:
Some files can contain viruses..yada yada yada....Would you like to open this file? um, yes...

is there a way around this? i saw an another post adding this into the macro for the page, but it didn't work:
Dim RetVal
RetVal = shell("C:\myfile.exe",1)

My last resort has been to set my security to "LOW" temporarily when I want to run PowerPoint presentations; which is very frequent.  I'd rather add a macro w/the correct coding to have it run automatically.  Just in case I forget to change the security settings back.
Comment
Watch Question

byundtMechanical Engineer
CERTIFIED EXPERT
Most Valuable Expert 2013
Top Expert 2013

Commented:
Hi mdmcq5,
I'm not getting the warning message. But if you are, consider surrounding your Shell statement with code to turn alerts off and then back on:

Private Sub CommandButton1_Click()
Dim RetVal
Application.DisplayAlerts = False
RetVal = Shell("C:\Program Files\IrfanView\i_view32.exe", 1)
Application.DisplayAlerts = True
End Sub

Cheers!

Brad

Author

Commented:
I'm not powerpoint guru & the presentation wasn't created by me & actually dont know how they added the button that leds to the .exe. But, anyway, if I just add this coding into a macro on that particular slide, the message should no longer appear?

& this line I should change to were the .exe file resides?
RetVal = Shell("C:\Program Files\IrfanView\i_view32.exe", 1)

& where can I check on this particular page to be certain they have named this linked button as CommandButton1?
byundtMechanical Engineer
CERTIFIED EXPERT
Most Valuable Expert 2013
Top Expert 2013

Commented:
mdmcq5,
If you right-click on the button (while in slide editing mode), you can choose "Properties" from the resulting pop-up. The name of the button is the "(Name)" property at the top of the Properties dialog.

If you choose "View code" after right-clicking the button, you will see the macro linked to that button.

I'm not a PowerPoint wizard either--but I do know my way around VBA. If you can find the statement that launches the .exe file in the macro, try surrounding it with the two statements in my previous post to turn Alerts off and then back on. I used the RetVal=Shell(... statement in my test presentation just  because that was the code you posted, and IrfanView was a handy .exe file to try running.
Brad

Author

Commented:
I'll take a look tomorrow; file on PC there. And will attempt your coding suggestion. Keep ya posted!
Freelance
Top Expert 2006
Commented:
Hello mdmcq5,

>> When I click to play the file the usual warning message pops up:
>> Some files can contain viruses..yada yada yada....Would you like to open this file? um, yes...

that warning only pops up when opening the powerpoint file not when running the code behind the button on button click so you do not need any additional code, turning off the security warnings under macro | security was enough

here is a sample ppt file containing that code which is familair ;-)

source: http://www.traktiq.net/ee_temp/ppt_21781745.ppt
----------
1. open your powerpint presentation
2. show the toolbox through view | toolbox
3. drag a button to the slide
4. doubleclick the button
5. the resulting eventhandler looks like

Private Sub CommandButton1_Click()

End Sub

6. add your lines to make it look like

Private Sub CommandButton1_Click()
  Dim RetVal
  RetVal = Shell("C:\myfile.exe", 1)
End Sub

7. change the path to your exe, eg this line

"C:\myfile.exe"

8. close the vb editor
9. run the presentation and click the button
----------

just comment on the results

hope this helps a bit
bruintje

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Ok, it's actually a picture containing a picture of a button and the whole page is linked to an "Action Setting" where the .exe is set under Mouse Click -> Run Program -> launch.exe

Author

Commented:
So, any additional input? was lowering the security the only option since the .exe was attached to a picture?
Brian MulderFreelance
Top Expert 2006

Commented:
yes it really shouldn't make a difference where the macro was attached to, that warning comes only from opening a file that contains a macro

Author

Commented:
The file being opened is an .exe file, and that is why the warning message is appearing.  There is no macro.  Is there something other than lowering the security on powerpoint, to stop the warning from appearing when attempting to launch the application attached to the powerpoint slide?  Macro coding?
the actual linking of the executable file is a powerpoint macro in itself. so in this case you must lower the security to prevent pop up warning essages occuring.

Author

Commented:
So, basically as I've said....What I did was the only option....I was referring more to adding coding into a macro to stop the pop-up; that's not an option or resolution?

Let's stop repeating ourselves, please....

Author

Commented:
according to everyone so far my original solution to my own question was the only option; unless someone else can chime in now..
My last resort has been to set my security to "LOW" temporarily when I want to run PowerPoint presentations; which is very frequent.  I'd rather add a macro w/the correct coding to have it run automatically.  Just in case I forget to change the security settings back.

Although, I answered my own question; I'm rewarding bruintje the points b/c he was more on target.  Even though this particular presentation does not contain any Command buttons for entering the End Sub commands to stop the pop ups.  Closing question this way is much quicker than waiting four days for admins to; especially when making the request counts towards your question count ->
>> When I click to play the file the usual warning message pops up:
>> Some files can contain viruses..yada yada yada....Would you like to open this file? um, yes...

that warning only pops up when opening the powerpoint file not when running the code behind the button on button click so you do not need any additional code, turning off the security warnings under macro | security was enough

here is a sample ppt file containing that code which is familair ;-)

source: http://www.traktiq.net/ee_temp/ppt_21781745.ppt
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.