Picture/Image/Attachment Resizing

Status
Not open for further replies.

Steven Proud

Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server 2013
In Word I had found some great VBA code to resize BOTH a selected item and all items in a word document.

FOR EXAMPLE IN WORD - TO RESIZE A SELECTED ITEM/PICTURE

Sub ResizePic40Percent()
'
' ResizePic Macro
'
' The macro first asks for a percentage by which you want to scale the selected image,
' offering 75 (75%) as the default. When you specify a percentage, the macro then checks
' to see if the selected graphic is an inline or a floating graphic.
' The reason for doing this is that the object specification is different in each case,
' as well as how the scaling is specified. Inline objects belong to the InlineShapes collection,
' while floating objects are set using the ShapeRange object.
'
Dim PecentSize As Integer
PercentSize = 40
If Selection.InlineShapes.Count > 0 Then
Selection.InlineShapes(1).ScaleHeight = PercentSize
Selection.InlineShapes(1).ScaleWidth = PercentSize
Else
Selection.ShapeRange.ScaleHeight Factor:=(PercentSize / 100), _
RelativeToOriginalSize:=msoCTrue
Selection.ShapeRange.ScaleWidth Factor:=(PercentSize / 100), _
RelativeToOriginalSize:=msoCTrue
End If
End Sub

FOR EXAMPLE IN WORD - TO RESIZE ALL ITEMS/PICTURES

Sub ResizeAllPictSize40Percent()
' If you want to resize all the graphics in your document by the same percentage,
' then you only need to modify the above macro so that it steps through each of
' the inline graphics and then each of the floating graphics.
Dim PercentSize As Integer
Dim oIshp As InlineShape
Dim oshp As Shape
PercentSize = 40
For Each oIshp In ActiveDocument.InlineShapes
With oIshp
.ScaleHeight = PercentSize
.ScaleWidth = PercentSize
End With
Next oIshp
For Each oshp In ActiveDocument.Shapes
With oshp
.ScaleHeight Factor:=(PercentSize / 100), _
RelativeToOriginalSize:=msoCTrue
.ScaleWidth Factor:=(PercentSize / 100), _
RelativeToOriginalSize:=msoCTrue
End With
Next oshp
End Sub

THE ABOVE VBA workks great!!!!!

So thought I would adapt this to Outlook since I have to always resize images and other stuff ALL DAY LONG.

The same code from WORD would NOT work in OUTLOOK :(

I found some other code that works IN OUTLOOK- TO RESIZE ALL ITEMS/PICTURES
It also works great!!!!


Public Sub ResizeAllPictSize40Percent()
' If you want to resize all the graphics in your document by the same percentage,
' then you only need to modify the above macro so that it steps through each of
' the inline graphics and then each of the floating graphics.
Set objDoc = ActiveInspector.WordEditor
Set objWord = objDoc.Application
Dim iShp As Word.InlineShape
Dim iSelection As Word.Selection
Dim PecentSize As Integer
PercentSize = 40

On Error Resume Next
For Each iShp In objDoc.InlineShapes
With iShp
If .ScaleHeight Then
.ScaleHeight = PercentSize
End If
If .ScaleWidth Then
.ScaleWidth = PercentSize
End If
End With
Next iShp
End Sub


MY PROBLEM,

I'm not best at VBA and I NEED to select ONLY one item of many and resize only that item.
I have tried many things without any luck or better understanding.
Help Please
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
The problem is with this line:
For Each iShp In objDoc.InlineShapes
Rather than using for each ishp, you need to identify the selected shape and process it. If you know it's always the first shape on the page (or 2nd etc) you can call it by number ishp(1), otherwise you need to get the selected object.
 

Steven Proud

Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server 2013
The problem is with this line:


Rather than using for each ishp, you need to identify the selected shape and process it. If you know it's always the first shape on the page (or 2nd etc) you can call it by number ishp(1), otherwise you need to get the selected object.
I have tried to find a way to find "the selected object" without luck. for example, I cannot find a ishp(1).selected property for each? This is really my whole question.
Should I have asked this question in the topic of "Ask in Programming and Forums"? Is that what you meant. I am sorry, but my first post ever on any website - I'm a little behind the times at age 46.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
The forum doesn't really matter, although Michael has a better chance of seeing it. (He's the resident programming expert.) I'll move the thread there.

Have you tried using ishp(1) as the selected shape object?
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
The very first macro should do it. All you usually need to do to make a Word macro running in Outlook (2007 and higher) is to get a reference on the Word.Selection object. Here's a sample, add its lines to the first one before it accesses the Selection object.
 

Steven Proud

Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server 2013
The very first macro should do it. All you usually need to do to make a Word macro running in Outlook (2007 and higher) is to get a reference on the Word.Selection object. Here's a sample, add its lines to the first one before it accesses the Selection object.
Thank you very much for the information - I finally have this working with the following Code as my working code.

Public Sub ResizePic40Percent()

' ResizePic macro
' The macro first will attempt scale the selected image to the specified percentage,
' the macro then checks to see if the selected graphic is an inline or a floating graphic.
' The reason for doing this is that the object specification is different in each case,
' as well as how the scaling is specified. Inline objects belong to the InlineShapes collection,
' while floating objects are set using the ShapeRange object.

Dim Ins As Outlook.Inspector
Dim Document As Word.Document
Dim Word As Word.Application
Dim Selection As Word.Selection

Set Ins = Application.ActiveInspector
Set Document = Ins.WordEditor
Set Word = Document.Application
Set Selection = Word.Selection

Dim PecentSize As Integer
PercentSize = 40

On Error Resume Next

If Selection.InlineShapes.Count > 0 Then
Selection.InlineShapes(1).ScaleHeight = PercentSize
Selection.InlineShapes(1).ScaleWidth = PercentSize
Else
Selection.ShapeRange.ScaleHeight Factor:=(PercentSize / 100), _
RelativeToOriginalSize:=msoCTrue
Selection.ShapeRange.ScaleWidth Factor:=(PercentSize / 100), _
RelativeToOriginalSize:=msoCTrue
End If

End Sub
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
A Unhandled exception: picture argument should be an image BCM (Business Contact Manager) 0
E What does mean this icon at the picture attached? Using Outlook 2
P Outlook 2010: Missing tab - "Format/Picture Tools" HELP! Using Outlook 3
Diane Poremsky Displaying a Picture on a Contact New Slipstick.com Articles 0
oliv- Reduce the size of picture attachments: programmatically Outlook VBA and Custom Forms 3
B Automatic picture download and changing email addresses Using Outlook 3
G Issues with accessing Outlook Contact Picture with VBA Outlook VBA and Custom Forms 4
iwshim mail merge and add the contact picture outlook 2013 Using Outlook 3
Paul Van Cotthem Outlook 2013 contact picture only visible in "People" view Using Outlook 4
R Embbedet Firmlogo als Attachment and Picture Using Outlook 1
P Outlook can not display picture inline. Using Outlook 7
P OL2010 - custom form contact picture Using Outlook 0
L How to inbed picture in new outgoing messae Using Outlook 2
T Word attached files open Word. Excel files open Picture Manager!! Using Outlook 2
R insert picture tab grey Using Outlook 1
D Sending mass e-mail (picture only) Using Outlook 1
F How to setup signature with Outlook 2007 with external picture Using Outlook 4
D Images showing up as X's in Outlook 2003 emails. Outlook is set to HTML and Prevent Picture downloa Using Outlook 2
H Setting a picture for background of email Using Outlook 1
L cannot print embedded excel picture... Using Outlook 3
K Missing Format and Picture Tools tabs in Outlook 2007 Using Outlook 1
M Opening jpg and picture files generally Using Outlook 1
N Outlook 2007 Picture Placeholder Using Outlook 1
R (GPO?) Setting that controls automatic picture download Outlook 2002 Using Outlook 3
B Inserting picture of my business card into my email signature in Outlook Using Outlook 2
R where did the 'send picture from the Internet' go in Outlook 2007? Using Outlook 1
O Inserting Picture into Email Signature on Outlook Version 9 Using Outlook 3
V Why does inserting picture with a small file size cause my Task file size to blow up? Using Outlook 3
S Unable to send picture files via Outlook. Using Outlook 2
M insert picture in body of email Using Outlook 1
K Picture in email shows as hyperlink to an email address Using Outlook 1
G Social Network picture to contact synching Using Outlook 2
E Changing the default picture folder? Using Outlook 2
R Red x when trying to insert picture into an email since upgrading to Office 2010 Using Outlook 2
K Signature Picture Using Outlook 1
B Outlook: Inserting illustrations (e.g., picture) in an e-mail Using Outlook 2
R inserting picture >>>> not dislaying Using Outlook 1
B Insert Clip Art into HTML message - find picture formatting toolbar too? Using Outlook 6
B Saving an embedded .jpg picture Using Outlook 4
M Setting Picture Defaults - Text Wrapping Using Outlook 0
T Email with picture attachments Using Outlook 2
7 Problems trying to attach a picture from the Windows 7 Pictures Library to an Outlook 2003 message (e.g. a new message) Using Outlook 3
I Outlook 2010 contact picture issue in email header Using Outlook 2
V problem e-mailing picture attachments. dialog box is open and certificate file is missing or has been corrupted requires reinstallation Using Outlook 0
M Outlook 2007, Viewing Emails and Picture Placeholders blocking details Using Outlook 2
S How to insert a picture programatically Outlook VBA and Custom Forms 12
C insert a picture Outlook VBA and Custom Forms 1
S How to add icon(or picture) field for each contact in contacts view Outlook VBA and Custom Forms 6
M Reply with picture in body of message Outlook VBA and Custom Forms 2
D Reply with a template loose the sender's embedded image Outlook VBA and Custom Forms 0
Similar threads


















































Top