Set application = WScript.CreateObject("PowerPoint.Application") ' Get arguments If WScript.Arguments.Length > 0 Then crop_shape = WScript.Arguments(0) Else Call Err.Raise(60003, , "Crop shape is not provided") End If ' SlideShowWindows is when the pp is in presentation mode If application.SlideShowWindows.Count > 0 Then Call Err.Raise(60002, , "PowerPoint is in presentation mode. Cannot perform operation.") Else shapeType = application.ActiveWindow.Selection.ShapeRange.Type If shapeType = "17" Or shapeType = "15" Then Err.Raise vbError, "", "It is not an image. Cannot perform operation." ElseIf shapeType = "1" Then ' 1 is Shape WScript.Echo "shapeType " & shapeType application.ActiveWindow.Selection.ShapeRange.AutoShapeType = crop_shape Else application.ActiveWindow.Selection.ShapeRange.AutoShapeType = crop_shape application.CommandBars.ExecuteMso("PictureCrop") End If End If