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
Bookmarks