How to auto execute a macro when opening a Powerpoint presentation? - macros

I have a pretty basic question, but could not find the answer on internet.In Powerpoint 2010, I have a macro that I would like to be executed everytime the Powerpoint document is opened. How to achieve this ?Thanks !

While Auto_Open doesn't run in a PowerPoint presentation, you can fake it. Add a CustomUI part to the presentation, then use the CustomUI OnLoad callback to run code when the presentation opens. The CustomUI part needs no more than just the CustomUI tags.
Get the Custom UI Editor from here: http://openxmldeveloper.org/articles/customuieditor.aspx
Open the presentation in the Custom UI Editor. Insert a CustomUI part from the Insert menu:
Now enter some simple RibbonX code, like this:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
onLoad="MyOnloadProcedure" >
</customUI>
Now write your on-open procedure:
Sub MyOnloadProcedure()
MsgBox "Hello"
End Sub
If you have both this and the Auto_Open procedure in an add-in, Auto_Open runs first.
Full disclosure: while I thought of using this approach and have used it in Excel, I waited until I first encountered it on the PPT Alchemy web site: Run Code When PowerPoint Opens.

I am using PowerPoint 2016 so I can't speak for earlier versions although the documentation indicates this works for PowerPoint versions 2016, 2013, 2010, 2007. This method DOES NOT require any add-ins or application hooks to handle events.
Reference link:
https://support.office.com/en-us/article/command-line-switches-for-microsoft-office-products-079164cd-4ef5-4178-b235-441737deb3a6?ocmsassetID=HA010153889&CTT=1&CorrelationId=ea39d200-aa81-4d6e-8302-afff4c65859e&ui=en-US&rs=en-US&ad=US#ID0EAABAAA=PowerPoint,_PowerPoint_Viewer)
Start PowerPoint from command line and use the /M switch to have PowerPoint run a specified macro when it starts a named presentation file.
The easiest way to do this is to create a shortcut to the PowerPoint application. Then go to the Properties window for the shortcut and select the Shortcut tab. Next, add the /M switch, your presentation file name (including path), and the name of the macro to run (case sensitive and must be part of the presentation) to the end of the Target field. Double-click the shortcut and voila!
Example:
My presentation is C:\myPPTpres.pptm and the macro is Run_Slide_Show so I will need to add
/M "C:\myPPTpres.pptm" "Run_Slide_Show" to the end of the existing text in the Target field.
"C:\Program Files (x86)\Microsoft Office\root\Office16\POWERPNT.EXE"
/M "C:\myPPTpres.pptm" "Run_Slide_Show"
Make sure you are running a macro-enabled version of the presentation (in 2016 it has the .pptm extension.)
Important note if you are trying to start a slide show automatically using the macro. Add a delay of one or more seconds at the very beginning of your macro to allow the application to finish its startup sequence. If you do not the slideshow will start but the application will steal focus as it completes its startup, pushing your slideshow to the background.

Assuming the type of macro to be Auto Events related such as Auto_open(), Auto_close(), Auto_print() etc., for powerpoint to execute macros on opening powerpoint file we require Powerpoint Add-Ins to be included or other option could be to save the file as .ppa or .ppam.
For more details and to download the AutoEvents zip file refer the link: http://skp.mvps.org/autoevents.htm

Related

How to write an Eclipse component (editor, launcher, ...) that can execute my custom DSL files?

Let's say I have defined a small little textual DSL and I have an 'interpreter' that will parse and execute commands of a file in that DSL.
What is the best way to start such an interpreter in Eclipse?
For instance, I want to double click on a file and, based on the fact that it has the extension .mydsl, start the interpreter. Another option could be using a launcher with "Run As ...".
So should I look at implementing a ...
custom launcher (extending org.eclipse.debug.core.launchConfigurationTypes, http://www.vogella.com/tutorials/EclipseLauncherFramework/article.html), or
editor, that is not actually editing the file, but will be called when the file is double clicked (extending EditorPart, https://wiki.eclipse.org/FAQ_How_do_I_create_my_own_editor%3F)
something else?
Thanks for any hints!
For that I would recommend to implement a custom launcher to get for free:
in main toolbar Run button with history support
ability to share launch configuration via version control (in Common tab choose Shared file)
Launch Group support
etc.
In Project Explorer, Package Explorer, Navigator and similar views a double-click opens a file. In order not to confuse the user you should not change this behavior. But in addition to the custom launcher you could consider to implement an editor with a run button similar to PDE's Product Configuration Editor or a view similar to the Ant view that shows your DSL scripts that can be run on double-click.

In Confluence Is There A Way to Display the Contents of an Attached File in a CODE BLOCK?

I am editing some Confluence pages and I need to display the contents of a SQL file on the page. I have attached the file and can copy and paste into a Code Block. But what they want is the attached file to show up displayed on the page. Is there a way (preferably in a code block so it can be formatted) to display the contents of a text file that is attached to the page actually on the page?
One possible way is if there is a macro that would take the attachment and write it to the page for you. There are a number of macros, but I don't know if one of them does what you are looking for. A quick look through the stock macros doesn't reveal an obvious answer. You could write your own, however.
Click on + Insert, Other Macros, and select Development, then check out the Cheese demo.
From the documentation:
To edit an existing macro: Click the macro placeholder and choose Edit. A macro dialog window will open, where you can edit the parameters of the macro.
The Code Block macro does support sql file formatting, but you would have to insert the content of the sql into the document. You might create a derivative of this macro to accomplish your goal.

Inject OnClick Event into running EXE

Is it possible with some program to to send an OnClick Event eg: MenuNewClick (File New) or others.
I have an application that has no Keyboard shortcuts.
When I use a Resource Editor I can see the Delphi Forms for each OnClick Event I need.
I would just like to be able to send these OnClick Events with Keyboard Shortcuts into the running exe.
Have used apps like Darker's Enabler, EDA Preview that allow you to modify the layout of a running exe.
Possible ?
Even this forum has options "Keyboard shortcuts
Enable keyboard shortcuts (when enabled, press ? for help)"
Thanks.
If the application is indeed made with Delphi and if it uses default TMainMenu component you could modify the RCData in which the .dfm is stored (this data alows you to view the form and its properties with programs like PE Exporer and similar) in a way that you change the AutoHotkeys property of TMainMenu to maAutomatic and then change ShortCut property of each menu item to contain proper keyboard shortcut.
If you have access to Delphi I recomend you first make an example application which will have all available shourctuts implemented so you could comparison the RCData between these two applications and made necessary changes.
NOTE: What I'm suggesting will require editing the EXE resource data so make sure you are working on a copy of the exe and not on the real one so you don't break your application.

How to ID a control with Windows Spy?

Newby here...I have my first script running...yeah! But I'd like to read some window controls. I see in the AHK Help for GetControlPos and others:
Can be either ClassNN (the classname and instance number of the control) or the name/text of the control, both of which can be determined via Window Spy.
Duh, I can't find the info in Windows Spy. Can someone point me in the right direction...TIA.
You have to hover over the controls with you mouse. In the "Under mouse" section you will see what can be gathered from the application. In quite a few situations, you will not see more that the colour under the mouse. When the application has named controls, you will then see the ClassNN name/ID.
In short, not all programs have named controls.
You can test with e.g. Notepad and in Notepad use file save. The file save dialog has named controls.

Evaluate live javascript edits in Chrome?

How do I tell the Chrome developer tools that I'm done live-editing a section of javascript, and want the result to be "evaluated"?
Editing the javascript on the fly is simple, I simply put the cursor somewhere in a script in the Scripts tab and start typing, but how do I finish the editing process?
I read here that "changes you apply to the code are expressed only at the time when execution passes through them", but even if I try editing a function when it's being called (i.e., when having a hit breakpoint inside it), I can't get my changes to be acknowledged. Edit: this whole, "execution passes through it" stuff seems false or out of date at best.
Editing javascript on the fly in the developer tools is demoed by Paul Irish in this video around 3:30, but I can't figure out how he goes from editing code, to having it actually be used by the browser.
Ctrl+S or "right-click > Save".
Make sure you haven't enabled pretty-print, as you can't live-edit code, then.
This is what you are looking for:
1.- Navigate to the Source tab and open the javascript file
2.- Edit the file, right-click it and a menu will appear: click Save and save it locally.
In order to view the diff or revert your changes, right-click and select the option Local Modifications... from the menu. You will see your changes diff with respect to the original file if you expand the timestamp shown.
More detailed info here: http://www.sitepoint.com/edit-source-files-in-chrome/
Go to sources, choose the file you want.
Click the pause button to pause debugging .
Modify the script adding a console.log or whatever you want, wherever you want
Save the file (cmd-s or ctrl-2)
Click the pause/resume button to resume execution
the modified code will be executed