使用命令按钮将所有图片压缩为电子邮件大小像素(96)PPI [英] Compress all the pictures to email size pixel (96)PPI by using command button

查看:196
本文介绍了使用命令按钮将所有图片压缩为电子邮件大小像素(96)PPI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过使用带有以下代码的命令按钮将excel工作簿中的所有图片压缩为电子邮件大小像素96(ppi).但是压缩所有图片均无效,只能压缩1张图片.

I want to compress all the pictures in excel workbook to email size pixel 96( ppi) by using command button with the following code. But it doesn't work to compress all pictures .It can only compress 1 picture.

Sub test()

    Dim wsh As Worksheet

    Set wsh = Worksheets("Sheet1")
    wsh.Activate
    wsh.Shapes(1).Select

    SendKeys "%e", True
    SendKeys "~", True
    Application.CommandBars.ExecuteMso "PicturesCompress"

End Sub

推荐答案

尝试使用 For Each 循环遍历工作表中的所有形状:

Try using a For Each loop to iterate through all shapes in the worksheet:

Sub test()

    Dim wsh As Worksheet
    Dim shp As Shape

    Set wsh = Worksheets("Sheet1")

    For Each shp In wsh.Shapes
        shp.Select
        SendKeys "%e", True
        SendKeys "~", True
        Application.CommandBars.ExecuteMso "PicturesCompress"
    Next shp

End Sub

这篇关于使用命令按钮将所有图片压缩为电子邮件大小像素(96)PPI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆