VBA increase JPG Picture size in Email

ashani

Active Member
Joined
Mar 14, 2020
Messages
347
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm using the below syntax in VBA to convert excel cells into JPG and paste onto email body and send email. It works fine, however I would like to increase the size of the picture - please could someone guide me how to do it?

VBA Code:
Sub Email_jpg()

Dim OutApp As Object
Dim OutMail As Object
Dim table As Range
Dim pic As Picture
Dim ws As Worksheet
Dim wordDoc
Dim a As String, b As String, c1 As String, c2 As String, c3 As String, d As String
 
Dim Rng As Range
Set ws = Worksheets("Sheet1")
Set Rng = ws.Range("A6:F20")
'sort data from smallest to largest number in column B
Rng.sort Key1:=Range("F:F"), Order1:=xlDescending

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

Set ws = ThisWorkbook.Sheets("Sheet1")
Set table = ws.Range("A3:F38")
ws.Activate
table.CopyPicture
Set pic = ws.Pictures.Paste
pic.Cut

On Error Resume Next
With OutMail
.To = Range("G1").Value
.CC = Range("J1").Value
.Subject = "XYZ"
.display

Set wordDoc = OutMail.GetInspector.WordEditor
            With wordDoc.Range
                .PasteandFormat wdChartPicture
                .insertParagraphAfter
                .insertParagraphAfter
                .InsertAfter "thanks,"
                .insertParagraphAfter
                .InsertAfter "ABC"
                .insertParagraphAfter
                .InsertAfter "XYZ"
                .insertParagraphAfter
                .InsertAfter
            End With
            
.HTMLBody = "<BODY style = font-size:11pt; font-family:Calibri >" & _
            "Hi, <p>xyz <p>" & .HTMLBody
    
    On Error Resume Next
    .send
    Application.Visible = True
    If Err Then
      MsgBox "E-mail was not sent", vbExclamation
    Else
      MsgBox "Email was sent!!", vbInformation
    End If
    On Error GoTo 0
    End With
    
Set OutApp = Nothing
Set OutMail = Nothing

End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Maybe something like this...

VBA Code:
    'etc
    '
    '
   
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
   
    Set ws = ThisWorkbook.Sheets("Sheet1")
    Set Table = ws.Range("A3:F38")
   
    Table.CopyPicture
   
    With OutMail
   
        .To = Range("G1").Value
        .CC = Range("J1").Value
        .Subject = "XYZ"
        .display
       
        Set wordDoc = OutMail.GetInspector.WordEditor
       
        With wordDoc.Range
            .PasteandFormat wdChartPicture
            .insertParagraphAfter
            .insertParagraphAfter
            .InsertAfter "thanks,"
            .insertParagraphAfter
            .InsertAfter "ABC"
            .insertParagraphAfter
            .InsertAfter "XYZ"
            .insertParagraphAfter
        End With
       
        'increase width and height by 50% (change as desired)
        With wordDoc
            With .inlineShapes(.inlineShapes.Count)
                '.LockAspectRatio = msoFalse
                .Width = .Width * 1.5
                '.Height = .Height * 1.5
            End With
        End With
               
       'etc
        '
        '
               
    End With

Hope this helps!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top