Compile Error sending pdf as attachment



I think i may have deleted a part of code ina module to now cause a Compile
The error is:
"Sub or Fuction Not Defined."

The error line is highlighted in the code below.

Can some help me fix this?

Sub SendPDF()
Dim OutApp As Object
Dim OutMail As Object
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = Sheet1.Range("B13").Value
.CC = Sheet1.Range("B15").Value
.BCC = ""
.Subject = Sheet1.Range("B63").Value
.Body = Sheet1.Range("B65").Value
If Not FileExists("\\Server\Pdf's\" & Range("G5").Value
& ".pdf") Then ' <=== ERROR
MsgBox "The pdf file doesn't exist! " & "Please check
the pdf File Name you just saved" & vbCrLf & vbCrLf & "It MUST be saved as
" & Sheet1.Range("G5").Value & " ONLY!", vbCritical, "...."
Exit Sub
.Attachments.Add ("\\Server\Pdf's\" & Range("G5").Value &
End If
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Sheet1.Range("B64").Value = Time & Date
Sheets("Information").Range("B64").Value =
Format(Sheets("Information").Range("B64").Value, "hh:mmAM/PM dddd dd mmmm
yyyy ")
End Sub




As the reference to Range("G5") is not fully referenced you may get an error
if the sheet from which G5 is referenced is not the active sheet.

Is the path a valid path?

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question