How to Programatically Compress Pictures/Images in Excel using VBA
If you are trying to compress pictures, you will normally be doing using the following dialog:
Compress Pictures Excel Dialog
The same dialog can be automated using Excel VBA and SendKeys as shown below:
Sub Compress_PIX() Dim octl As CommandBarControl With Selection Set octl = Application.CommandBars.FindControl(ID:=6382) Application.SendKeys "%e~" Application.SendKeys "%a~" octl.Execute End With End Sub
Supressing "Compressing Pictures May reduce the quality of your images.." dialog is also taken care by SendKeys
The code uses CommandBarControl to find the Command and then execute the dialog
how can i select 96dpi?
ReplyDeleteHow do you get to this dialog box ???
Delete