iT邦幫忙

0

VBA outlook 貼上圖片自訂長寬

vba
  • 分享至 

  • xImage

https://ithelp.ithome.com.tw/upload/images/20220912/20109231xgFUowUEw4.png
https://ithelp.ithome.com.tw/upload/images/20220912/201092311kbMcrxKKd.png

以下程式碼是複製範圍以圖片貼上至OUTLOOK信件,想請教2個問題:

  1. 怎麼自動設定貼上圖片的高&寬?例如希望設定圖片為高5、寬16。
  2. 怎麼自動設定文繞圖為上及下?例如圖二。

以上求解~~~謝謝

Sub test()
Range("B2:H8").Select
Selection.Copy

Dim wordDoc As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

With OutMail
    .To = ""
    .Subject = ""
    .Display
    
    Set wordDoc = OutMail.GetInspector.WordEditor
    wordDoc.Range(Start:=0, End:=1).PasteAndFormat 13
End With
End Sub
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
blanksoul12
iT邦研究生 5 級 ‧ 2022-09-13 08:49:36
最佳解答
Sub test()
Dim wordDoc As Object

Range("B2:H8").Select
Selection.Copy

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

With OutMail
    .To = ""
    .Subject = ""
    .Display
    
    Set wordDoc = OutMail.GetInspector.WordEditor
    wordDoc.Range(Start:=0, End:=1).PasteAndFormat 13
    wordDoc.InlineShapes(1).LockAspectRatio = msoFalse
    wordDoc.InlineShapes(1).Height = 5 * 28.35
    wordDoc.InlineShapes(1).Width = 16 * 28.35

End With

End Sub

28.35 應該是營幕點數換算公分的倍數,可能和你的不同,你可設定斷點在 end with 那然後看看 wordDoc.InlineShapes(1) 內的 height 及 width.

文繞圖找不到.

blanksoul12 太感謝了,已解決我一個大問題耶!!! 讚~~~

我要發表回答

立即登入回答