Hello there. I get a 'Type mismatch' error on the following code. It worked fine so far so I don't know where this hissy fit comes from.
I think the error is in this line: strAttachment = sh2.[A1].Value & sh1.Cells(r, 2) & "_" & sh1.Cells(r, 3) & ".pdf"
Code
Sub SendInvoice()
'Working in Office 2000-2010
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim SigString As String
Dim Signature As String
Dim TxtString As String
Dim BodyTxt As String
Dim strSubject As String
Dim strAttachment As String
Dim strInvoiceDetail As String
Dim strPOInfo As String
Dim strReq As String
Dim strPO As String
Dim strRec As String
Dim strPath As String
'Your Sheet names need to be correct in here
Set sh1 = Sheets("Invoices")
Set sh2 = Sheets("InvoicePath")
r = ActiveCell.Row
strPath = sh2.[A1].Value
On Error GoTo Errorcatch
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strSubject = "NZ " & sh1.Cells(r, 5) & " Invoice: " & sh1.Cells(r, 2) & " " & sh1.Cells(r, 3) & " - " & "PO 640120000" & sh1.Cells(r, 7) & " - " & sh1.Cells(r, 8) & sh1.Cells(r, 11)
strbody = "Dear Gagan"
strInvoiceDetail = "Please find attached " & sh1.Cells(r, 5) & " invoice " & sh1.Cells(r, 2) & " " & sh1.Cells(r, 3) & " for " & sh1.Cells(r, 8) & sh1.Cells(r, 10) & " for payment."
strReq = "Requisition: 64011000" & sh1.Cells(r, 6) & vbNewLine
strPO = "PO: 64012000" & sh1.Cells(r, 7) & vbNewLine
strRec = "Receipt: 64013000" & sh1.Cells(r, 12) & vbNewLine
strAttachment = sh2.[A1].Value & sh1.Cells(r, 2) & "_" & sh1.Cells(r, 3) & ".pdf"
'Location of the e-mail signature you use
SigString = "C:\Users\305015724\AppData\Roaming\Microsoft\Signatures\ChristineSignature.txt"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
On Error Resume Next
With OutMail
.To = "~Health ANZ Payables>"
.CC = "Gagandeep"
.BCC = ""
.Subject = strSubject
.Body = strbody & vbNewLine & vbNewLine & strInvoiceDetail & vbNewLine & vbNewLine & strReq & strPO & strRec & vbNewLine & "Thank you." & vbNewLine & vbNewLine & Signature
.Attachments.Add strAttachment
.Display 'or use .Send
sh1.Cells(r, 15).Value = Date
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Exit Sub
Errorcatch:
MsgBox Err.Description
End Sub
Display More
Help, please! Thank you.