Results 1 to 1 of 1

Help with Copy Range from Tab and Paste In Outlook Email Message Body.

Threaded View

  1. #1
    Registered User
    Join Date
    06-25-2014
    Location
    Cali
    MS-Off Ver
    2010
    Posts
    1

    Help with Copy Range from Tab and Paste In Outlook Email Message Body.

    Hi Guys,

    I have a tab in my workbook, named "Master Summary". I would like to include a copy/image range from this tab and paste it in my macro below, so that it's included with the body of the email. Again the name of the tab i want to 'copy' image range from to outlook, is the "Master Summary" tab, ...May someone help me out please?

    Here is my macro:
    Sub Open_Orders()
    '
    ' Open_Orders Macro
    '
    
    Dim EAdd As String, QTR As String
        Dim Source As Range
        Dim Dest As Workbook
        Dim wb As Workbook
        Dim MyStr As String
        
        
    Sheets("Summary").Select
            
        'Date = Cells(1, 3).Value
    
        
        '1. Formats workbook and Refreshes all pivot tables
        
                Dim sFileName As String, sPath1 As String, sPath2 As String, ThisFile1 As String, ThisFile2 As String, ThisFile3 As String
                Dim sPath3 As String, sPath4 As String
                Application.DisplayAlerts = False
                
                
           sPath1 = "\\somedrivefilesrx1\all2\ElvisPresley\Daily Numbers"
                sPath2 = Range("C1").Value
                    
                    
        Sheets("Raw Data").Select
        Columns("A:M").Select
        Selection.Copy
        Sheets("Open Orders").Select
        Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("Raw Data").Select
        Columns("N:AB").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Open Orders").Select
        Range("O1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    
    
    
    
    Sheets("Open Orders").Select
        Range("A1").Select
        ActiveCell.FormulaR1C1 = "BU"
        Range("B1").Select
        ActiveCell.FormulaR1C1 = "Cust #"
        Range("C1").Select
        ActiveCell.FormulaR1C1 = "Customer"
        Range("D1").Select
        ActiveCell.FormulaR1C1 = "GL Date"
        Range("E1").Select
        ActiveCell.FormulaR1C1 = "Inv #"
        Range("F1").Select
        ActiveCell.FormulaR1C1 = "Inv Date"
        Range("G1").Select
        ActiveCell.FormulaR1C1 = "Order #"
        Range("H1").Select
        ActiveCell.FormulaR1C1 = "Item #"
        Range("I1").Select
        ActiveCell.FormulaR1C1 = "Desc"
        Range("J1").Select
        ActiveCell.FormulaR1C1 = "Price Rule"
        Range("K1").Select
        ActiveCell.FormulaR1C1 = "Qty"
        Range("L1").Select
        ActiveCell.FormulaR1C1 = "Unit Price"
        Range("M1").Select
        ActiveCell.FormulaR1C1 = "Qty of Unit Price"
        Range("O1").Select
        ActiveCell.FormulaR1C1 = "Ext. Price US$"
        Range("P1").Select
        ActiveCell.FormulaR1C1 = "Ext. Cost US$"
        Range("Q1").Select
        ActiveCell.FormulaR1C1 = "Ext. Price CAN$"
        Range("R1").Select
        ActiveCell.FormulaR1C1 = "Ext. Cost CAN$"
        Range("S1").Select
        ActiveCell.FormulaR1C1 = "Order Type"
        Range("T1").Select
        ActiveCell.FormulaR1C1 = "Prd Family"
        Range("U1").Select
        ActiveCell.FormulaR1C1 = "Class#"
        Range("V1").Select
        ActiveCell.FormulaR1C1 = "SubClass#"
        Range("W1").Select
        ActiveCell.FormulaR1C1 = "3rdClass"
        Range("X1").Select
        ActiveCell.FormulaR1C1 = "Country"
        Range("Y1").Select
        ActiveCell.FormulaR1C1 = "PO#"
        Range("Z1").Select
        ActiveCell.FormulaR1C1 = "Transaction Date"
        Range("AA1").Select
        ActiveCell.FormulaR1C1 = "Requested Date"
        Range("AB1").Select
        ActiveCell.FormulaR1C1 = "Last Status Code"
        Range("AC1").Select
        ActiveCell.FormulaR1C1 = "Next Status Code"
        Range("A1").Select
           
     'Sheets("Sheet1").Select
      '  Cells.Select
       ' Selection.Delete
                
     
     With Sheets("Open Orders")
             LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
              .Range("N2:N" & LastRow).Formula = "=IF(RC[5]=""R6"",RC[1],RC[-1]*RC[-2])"
              .Range("AD2:AD" & LastRow).Formula = "=MONTH(RC[-4])"
              .Range("AE2:AE" & LastRow).Formula = "=YEAR(RC[-5])"
              .Range("AF2:AF" & LastRow).Formula = "=MONTH(RC[-5])"
              .Range("AG2:AG" & LastRow).Formula = "=YEAR(RC[-6])"
              .Range("AH2:AH" & LastRow).Formula = "=IF(ISNA(VLOOKUP($B2,'Exclude List'!$B:$B,1,0))=TRUE,""Include"",""Exclude"")"
      End With
    
    
    'Hides the raw data tab
       'Sheets("Raw Data").Select
       ' ActiveWindow.SelectedSheets.Visible = False
     
    Call RefreshAllPivots
                
     Sheets("Summary").Select
    
      '=IF(S2="R6",O2,M2*L2)
      
                
       '2. Save workbook and tab as the derived cell specified
                
                
               
    
                FileExtStr = ".xlsx": FileFormatNum = 51
                ActiveWorkbook.SaveAs (sPath1 & "\" & sPath2) & FileExtStr, _
                FileFormat:=xlOpenXMLWorkbook
                
                
    
    Set wb = ActiveWorkbook
    With wb
    
    MyStr = Format(Date, "YYMMDD")
    'Sheets("Summary").Name "sPath2"
    
    End With
    
    '3 This portion sends the report as an email to a recipient
                Dim OutApp As Object
                Dim OutMail As Object
                Dim strbody As String
                Dim SigString As String
                Dim Signature As String
            
                Set OutApp = CreateObject("Outlook.Application")
                Set OutMail = OutApp.CreateItem(0)
                    
    
    
                strbody = "Hello," & vbNewLine & vbNewLine & _
                          "Attached are " & sPath2 & "." & vbNewLine & vbNewLine & _
                          "If you have any questions please contact me." & vbNewLine & vbNewLine & _
                          "Thank you." & vbNewLine & Signature
                            
                On Error Resume Next
                With OutMail
                .To = "USA Report"
                .CC = "ElvisPresely23@email.com"
                .BCC = " "
                .Subject = sPath2
                .Body = strbody & vbNewLine
                '.Attachments.Add ActiveWorkbook.FullName
    
                        
                 With OutMail
                    .To = "USA Report"
                    .CC = "ElvisPresely23@email.com"
                    .BCC = " "
                    .Subject = sPath2
                    .Attachments.Add (sPath1 & "/" & sPath2) & FileExtStr
       
                    .Body = strbody & vbNewLine & Signature
                    .Display '.Send   .Display '.Send  'or use
                        
                        
                        
                        
                End With
                On Error GoTo 0
                
                Set OutMail = Nothing
                Set OutApp = Nothing
            
             'ActiveWorkbook.Close SaveChanges:=True
             Application.DisplayAlerts = True
                
            'End If
            End With
                
    
    
    End Sub
    Last edited by vlady; 06-26-2014 at 03:12 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy and paste Excel range as picture into Outlook email body using excel vba
    By ExcelDoc in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-17-2016, 09:29 PM
  2. Is there a way to Copy And Paste Excel Range As Picture Into Outlook Email Body Using Exc
    By dineshsachidananda in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-17-2014, 09:00 AM
  3. Copy and Paste Union of Ranges/Rows to Outlook Email Body
    By darkhunter in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-10-2012, 01:52 PM
  4. Copy a range to the body in email message
    By CobraLAD in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-24-2008, 02:52 PM
  5. Copy and paste 2 excel sheets in message body of email
    By rrmando in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-03-2006, 05:10 PM

Tags for this Thread

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