+ Reply to Thread
Results 1 to 4 of 4

Emailing range problem???

Hybrid View

Johnny247 Emailing range problem??? 06-19-2014, 01:32 PM
mrice Re: Emailing range problem??? 06-19-2014, 02:32 PM
Johnny247 Re: Emailing range problem??? 06-19-2014, 02:56 PM
Johnny247 Re: Emailing range problem??? 06-19-2014, 03:20 PM
  1. #1
    Forum Contributor
    Join Date
    12-18-2013
    Location
    Kings Lynn, England
    MS-Off Ver
    Excel 2021
    Posts
    236

    Post Emailing range problem???

    Hi,
    I have some code(below), that I am trying to use to select a range, then email as a picture.
    However, it comes up with a syntax error in the first row.
    Does anyone have any ideas on this please??

    Thanks in advance.
    Sub eMailPictureInBody()
    ''' Set Range you want to export to file
        Dim rgExp As Range
        Dim OutApp As Object
        Dim OutMail As Object
    
    
     Set rgExp = Agency Order Sheet.Range("E1:AG22")
        ''' Copy range as picture onto Clipboard
        rgExp.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
        ''' Create an empty chart with exact size of range copied
        With ActiveSheet.ChartObjects.Add(Left:=rgExp.Left, Top:=rgExp.Top, _
                                          Width:=rgExp.Width, Height:=rgExp.Height)
            .Name = "Pict1"
            .Activate
        End With
        
        ''' Paste into chart area, export to file, delete chart.
        ActiveChart.Paste
        ActiveSheet.ChartObjects("Pict1").Chart.Export "C:\temp\Pict1.jpg" '
        ActiveSheet.ChartObjects("Pict1").Delete
    
    
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
    
        On Error Resume Next
        With OutMail
            .To = "xxxxxxxx@aol.com"
            .CC = ""
            .BCC = ""
            .Subject = "Agency requirements for Sunday"
            .HTMLBody = .HTMLBody & "<img src='c:\temp\pict1.jpg'>"
            .Display
            .Send   'or use .Display
            '
        End With
        On Error GoTo 0
    
        Set OutMail = Nothing
        Set OutApp = Nothing
    
    End Sub
    Last edited by Leith Ross; 06-19-2014 at 02:37 PM. Reason: Addded Code Tagas

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Emailing range problem???

    Your line of code has spaces in it. May be you need something like (if the caption on the tab is Agency Order)

    Set rgExp = Sheets("Agency Order").Range("E1:AG22")

  3. #3
    Forum Contributor
    Join Date
    12-18-2013
    Location
    Kings Lynn, England
    MS-Off Ver
    Excel 2021
    Posts
    236

    Re: Emailing range problem???

    Thanks for that.
    I have tried it again now with that line of code, but unfortunately, it now comes up with "Subscript out of Range". Do you have any suggestions please?
    Thanks.
    Johnny247

  4. #4
    Forum Contributor
    Join Date
    12-18-2013
    Location
    Kings Lynn, England
    MS-Off Ver
    Excel 2021
    Posts
    236

    Re: Emailing range problem???

    Figured it out! Thanks for your help ( It was the temp file path needed changing)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Emailing a selection of spreadsheet problem / Tab name needs omitting
    By peejaygee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2014, 03:47 AM
  2. Problem Emailing Excel sheets via Groupwise
    By Kholmes11 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2012, 01:18 PM
  3. Help emailing worksheet range via Redemption
    By Timothy.Rybak@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-17-2006, 04:00 PM
  4. [SOLVED] emailing problem
    By William Barnes in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-27-2005, 06:05 PM
  5. [SOLVED] Emailing document external link problem
    By Optiglaze in forum Excel General
    Replies: 2
    Last Post: 08-01-2005, 11:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1