I have a few programs setup where I can use Maestro to change font colors and automatically bold text at the same time. I edit many powerpoints and cannot figure out how to do this with this single program.
Anyone have ideas with creating something that will allow me to highlight some text, press a hotkey, then have the text change to a specific color and bold at the same time?
My preference would be to use a PPT VBA Macro when the automation is entirely within the Office app.
You can easily get started just by recording a VBA macro and going through the manual steps to format your text. Then, if necessary, you can fine-tune the Macro. Of course you can assign a shortcut key to the VBA macro.
@JMichaelTX Thanks for letting me know. I am not very familiar with VBA and it looks rather complicated. Do you happen to know of a good resource I can learn how to do this from? What I am finding on Microsoft's website and Google searches is assuming previous knowledge of VBA.
I wasn't able to figure out how to record the macro with PowerPoint. I see the option in Excel but when recording there and then trying to run it in PowerPoint I get errors.
I was able to find this code that works really well:
Sub FontColor_ChartTitle()
With ActivePresentation.Slides(1)
ActiveWindow.Selection.TextRange.Font.Color = RGB(0, 0, 0)
End With
End Sub
Only problem now is I don't see how to assign a hotkey to this macro.
@David1, my sincere apologies for leading you down a blind, dead-end alley.
Microsoft has really screwed us in PowerPoint by not providing the same level of VBA support as they do for Word and Excel.
So, forget about PPT VBA.
Fortunately, PPT is very scriptable. The Scripting Dictionary is very comprehensive.
To view it, open Script Editor, and then File > Open Dictionary > Microsoft PowerPoint.
IAC, I am more than willing to help you with this, and here is an AppleScript to set the font properties of the selected text:
tell application "Microsoft PowerPoint"
tell active presentation
tell active window
tell document window 1
set oSel to its selection
set oText to text range of oSel
tell font of oText
set font name to "Lucida Grande" -- "Futura"
set font size to 24
set font color to {255, 0, 0} -- red
set bold to true
end tell
end tell
end tell
end tell
end tell
return
I assume you know how to put this script into an Execute AppleScript in a Macro, which of course you can set any hot key trigger you like.
My experience with scripting Microsoft Office products - both Excel and PowerPoint in my case - is they are fairly tough to automate from outside. But it usually can be done.
For example, I have a macro that changes the size of a graph in Excel to be 20cm high and 30cm wide. (I use this for standardisation.) I have another one that (slightly) reduces the interactions needed to save an Excel graph as a .png file.
The former required UI scripting (hard fought through UI Browser). The latter required menu manipulation.
Most of what you want in Office isn’t even available in menus - as Keyboard Maestro would know them.
What I’d like to know with the VBA route is
How you can store a macro outside of a presentation or spreadsheet.
How eg Keyboard Maestro could invoke such a macro.
Most of my recent experience with VBA is with Word and Excel. Both of those apps provide excellent VBA support. Until this topic I had not used VBA with PowerPoint for many years -- in fact it was back in my "Windows" days. What I found today is that PPT has very poor support for VBA, while it has excellent support for AppleScript.
Of course, neither of these uses VBA. Frankly I'm surprised that these tasks could not be done with Excel VBA, but without testing I don't really know.
Q1. VBA macros can't be effectively used outside of the MS Office app that they were written for.
You can store VBA macros in the Excel Personal Workbook, and in the Word Normal Template, that can be accessed by any other Excel workbook (or Word document).
Q2. The only way for KM to invoke a VBA macro would be using AppleScript .
Here is an example AppleScript that I have used with Office 2011, but NOT with Office 365.
(it may or may not work with Office 365)
tell application "Microsoft Excel"
activate
--- FORMAT:
-- Do NOT use "macro name" as part of the command
-- Do NOT include the Module name
-- But, if the macro is in your Personal Macro Workbook (available to all documents,
-- then you must use it as a prefix in single quotes:
run VB macro "'Personal Macro Workbook'!Test_Macro"
end tell
tell application "Microsoft Word"
activate
--- FORMAT:
-- You must use "macro name" followed by the name in quotes
-- You must prefix the name with the Module name, "KM" in this case
-- Nothing special needed just because the macro is in the Word Normal Template
run VB macro macro name "KM.Test_Macro"
end tell