如何在 Outlook 中使用 VBA 创建宏来调整图像大小 [英] How to use VBA in Outlook to create a macro to resize an image

查看:141
本文介绍了如何在 Outlook 中使用 VBA 创建宏来调整图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的上一个问题,Outlook 正在以 125% x 125% 的默认大小粘贴来自截图工具的屏幕抓取,而我希望它是 100% x 100%.代替实际更改默认设置,我想制作一个宏来调整图像大小.

As noted in a previous question of mine, Outlook is pasting screen grabs from the Snipping Tool in a default size of 125% x 125%, whereas I'd like it to be 100% x 100%. In lieu of actually changing the default setting, I'd like to make a macro to resize the image.

我在 VBA PowerPoint 中做过类似的事情,但每个应用程序似乎都不同.例如,我尝试了代码

I've done similar things in VBA PowerPoint, but each application seems to be different. For example, I tried the code

Sub Resize_Outlook4()
    With ActiveDocument.InlineShapes(1)
        .ScaleHeight = 150
        .ScaleWidth = 150
    End With
End Sub

遵循 MSDN 中的示例,这应该将所有内联形状的大小调整为 150% x 150%,但这会导致错误运行时错误 '424':需要对象".

following an example from MSDN, which should resize all the inline shapes to 150% x 150%, but this leads to an error "Run-time error '424': Object required".

简而言之,我无法指定代表当前所选图片或仅代表电子邮件中所有图片的对象.有人知道如何正确执行此操作吗?

In short, I'm having trouble specifying an Object which would represent the currently selected picture, or just all the pictures in the e-mail. Does anybody know how to do this correctly?

推荐答案

我认为这应该可行,但我仍然建议简单地更改默认设置...

I think this should work, but I still recommend simply changing the default settings...

Sub Resize150()

    Dim objDoc As Object
    Dim shp As Object
    'Get the word-editor of the mail item
    If Application.ActiveInspector Is Nothing Then Exit Sub
    Set objDoc = Application.ActiveInspector.WordEditor
    For Each shp In objDoc.InlineShapes
        If shp.HasPicture Then
            shp.ScaleHeight = 150
            shp.ScaleWidth = 150
        End If
    Next

End Sub

这篇关于如何在 Outlook 中使用 VBA 创建宏来调整图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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