I am trying to cycle through all the sheets in my workbook and compress all pictures. I know there is a way to save my file with this option, but I would like to put this in the VBA so that it would be triggered each time the file is closed. I tried to search the interwebs and it gave me a starting point. The following script seems to work for the first sheet, but not the second, and every time it runs my number lock is changed. What do you think?
VBA Code:
Dim ws As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each ws In Application.ActiveWorkbook.Worksheets
ws.Shapes.SelectAll
SendKeys "%w", True
SendKeys "~", True
Application.CommandBars.ExecuteMso "PicturesCompress"
Next
Application.DisplayAlerts = True