+ Reply to Thread
Results 1 to 3 of 3

Send Range of Cells as an Attachment

Hybrid View

  1. #1
    Registered User
    Join Date
    04-08-2010
    Location
    Northumberland, England
    MS-Off Ver
    Excel 2003
    Posts
    44

    Send Range of Cells as an Attachment

    I have a worksheet designed as a form that I update and email to an external agency quite regularly. The basic premise is a button that when clicked saves a range of cells into the body of an email then sends to said agency.

    I am currently using the following code:

    Private Sub cmdEmail_Click()
    
    ActiveWorkbook.Sheets("Sheet 1").Activate
    
       ActiveSheet.Range("B2:G8").Select
       
       ActiveWorkbook.EnvelopeVisible = True
    
       With ActiveSheet.MailEnvelope
          .Introduction = "Weekly Table Figures"
          .Item.To = "[email protected]"
          .Item.Subject = "Table No"
          .Item.Send
    
       End With
    
    ActiveWorkbook.Sheets("Sheet 1").Activate
    
    Range("A1").Select
    
    
    Unload Me
    
    End Sub
    Instead of sending the cells in the body, I would like to send thenm as an attachment.

    The attached workbook is an example of the cell range plus an explanation of what I need.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Send Range of Cells as an Attachment

    Hi,
    you might find help at Ron de Bruin's page

  3. #3
    Registered User
    Join Date
    04-08-2010
    Location
    Northumberland, England
    MS-Off Ver
    Excel 2003
    Posts
    44

    Re: Send Range of Cells as an Attachment

    I would do but I dont know how to tailor it to my situation. I have a user form to input data. When I press submit the data from the userform populates certain cells within a range. with regards to the code on ron de bruin's page, how would I incorporate that into the code I have for the Submit button? Code below.


    Private Sub cmdSubmit_Click()
    ActiveWorkbook.Sheets("Sheet 1").Activate
    
        Range("C1").Select
    
        Do
    
    If IsEmpty(ActiveCell) = False Then
    ActiveCell.Offset(1, 0).Select
    
    End If
    
    Loop Until IsEmpty(ActiveCell) = True
    ActiveCell.Value = txt1.Value
    ActiveCell.Offset(0, 1) = txt2.Value
    ActiveCell.Offset(0, 2) = txt3.Value
    ActiveCell.Offset(0, 3) = txt4.Value
    ActiveCell.Offset(0, 4) = txt5.Value
    ActiveCell.Offset(0, 5) = txt6.Value
    ActiveCell.Offset(0, 6) = txt7.Value
    ActiveCell.Offset(0, 7) = txt8.Value
    
    With Sheets("Sheet 1").PageSetup
                        .PrintArea = "B2:G8"
                        .FitToPagesWide = 1
                        .FitToPagesTall = 1
                    End With
                    Sheets("Sheet 1").PrintOut
    
       ActiveSheet.Range("B2:G8").Select
       
       ActiveWorkbook.EnvelopeVisible = True
    
       With ActiveSheet.MailEnvelope
          .Introduction = "Weekly Table Figures"
          .Item.To = "[email protected]"
          .Item.Subject = "Table No"
          .Item.Send
    
       End With
    
    ActiveWorkbook.Sheets("Sheet 1").Activate
    
    Range("A1").Select
    
    
    Unload Me
    
    End Sub
    Ron's code is for attaching the range as a workbook. In my situation, I am unable to send .xls documents.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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