PDA

View Full Version : Excel 2013 - Picture Compression Macro



MCBrad
07-08-2013, 07:49 PM
I have searched for a way to program a macro to automate picture compression, and have found numerous options listed online. The only problem is that none of them seem to work for Excel 2013.
I received a last-minute upgrade to Office (2010 to 2013), and now some of my macros no longer work.

Below are come code examples that I have found online and tried.

Examples:



Dim octl As CommandBarControl
Set octl = Application.CommandBars.FindControl(ID:=6382)
Application.SendKeys "%e~~"
octl.Execute
This seems to work fine for older versions of Office (pre 2007)

__________________________________________________ __________________


Application.SendKeys "%(oe)~{TAB}~"
Application.CommandBars.ExecuteMso "PicturesCompress"
This seems to work for Office 2007 & 2010

__________________________________________________ __________________

These are options that I have tried for 2013, and have had no success so far...


If Application.Version >= 14 Then
'Application.SendKeys "a", True
'Application.SendKeys "s", True
'Application.SendKeys "{Enter}", True
'Application.CommandBars.ExecuteMso "PicturesCompress"

'Pic.Activate
'SendKeys "%JP", True
'SendKeys "%m", True
'SendKeys "ae", True
'SendKeys "Enter", True


Dim octl As CommandBarControl
Set octl = Application.CommandBars.FindControl(ID:=6382)
Application.SendKeys "%e~"
Application.SendKeys "%a~"
octl.Execute

End If

__________________________________________________ ____________________


I can use Application.CommandBars.ExecuteMso "PicturesCompress" in order to open the dialog box, but sendkeys don't seem to have focus on the pop-up window.
I would prefer to not leave the choices up to the end-user if at all possible.


Any help would be greatly appreciated.

Edit: Please use code tags when posting codes. This time I added for you.

Kenneth Hobson
07-11-2013, 07:24 PM
Did you disable UAC?