I wrote a program in excel 2016 with macros by creating a button to send mail to recipient
B16 cell contains my recipient mail id
when i run this code it shows me the error ofimage1
and
image 2 error
in this particular line it shows me this error
please help me with this error
and also now outlook is changed to outlook new (this also the one reason for getting this error)
when i run the code it should go to mail but it shows me this error
Please Help ASAP
`Sub EmailasPDF()
Dim EApp As Object
Set EApp = CreateObject(“Outlook.Application”)
Dim EItem As Object
Set EItem = EApp.CreateItem(0)
Dim invno As Long
Dim custname As String
Dim amt As Currency
Dim dt_issue As Date
Dim pay_type As String
Dim ref_no As String
Dim term As Byte
Dim path As String
Dim fname As String
Dim nextrec As Range
invno = Range("C3")
custname = Range("B11")
amt = Range("H42")
dt_issue = Range("C5")
pay_type = Range("C6")
term = Range("C7")
ref_no = Range("C8")
path = "C:YEZLAW INVOICES DATAPDF format"
fname = invno & " - " & custname
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, IgnorePrintAreas:=False, Filename:=path & fname
Set nextrec = Sheet3.Range("A1048576").End(xlUp).Offset(1, 0)
nextrec = invno
nextrec.Offset(0, 1) = custname
nextrec.Offset(0, 2) = amt
nextrec.Offset(0, 3) = dt_issue
nextrec.Offset(0, 4) = dt_issue + term
nextrec.Offset(0, 6) = pay_type
nextrec.Offset(0, 9) = ref_no
nextrec.Offset(0, 10) = Now
Sheet3.Hyperlinks.Add anchor:=nextrec.Offset(0, 7), Address:=path & fname & ".pdf"
With EItem
.To = Range("B16")
.Subject = "Invoice no: " & invno
.Body = "Please find Invoice attached."
.Attachments.Add (path & fname & ".pdf")
.Display
End With
End Sub`
Help me with this and macro code for this error
Zeez Xerox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1