I need to use the Snipping Tool to capture a few screenshots, then copy & paste it into my Outlook Email template.
After I paste the pictures into the Email template, I want the images to change to a width of 9cm (255 ps) in a click of a button. The codes behind the button will run on the current item open.
That is, the code will have to run through the current item that is open and identify the image object, and run the codes to change the width of the image (with aspect ratio turned on).
I have done a little coding as shown below but I can't make it run. Can anyone help me on this?
p.s. I did a search and figured that ShapeRange only apply for Word, Powerpoint, Excel, Project, etc.
Option Explicit
Sub ChangeWidth()
Dim objApp As Outlook.Application
Dim objItem As Outlook.MailItem
Dim OrigShape As ShapeRange
Dim image As Object
Set objApp = Application
Set objItem = objApp.ActiveInspector.CurrentItem
objItem.ShapeRange.LockAspectRatio = msoTrue
objItem.ShapeRange.Width = 255.1181103
End Sub
You need to use InlineShapes
:
Option Explicit
Sub ChangeWidth()
Dim objApp As Outlook.Application
Dim objItem As Outlook.MailItem
Dim iShape As InlineShape
Dim image As Object
Set objApp = Application
Set objItem = objApp.ActiveInspector.CurrentItem
For Each shp In objItem.InlineShapes
If shp.HasPicture Then
shp.LockAspectRatio = msoTrue
'shp.ScaleHeight = 150
'shp.ScaleWidth = 150
'or
shp.Width = 255.1181103
End If
Next
End Sub