PC Review


Reply
Thread Tools Rate Thread

Compile Error sending pdf as attachment

 
 
Corey
Guest
Posts: n/a
 
      29th Sep 2008
I think i may have deleted a part of code ina module to now cause a Compile
Error.
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")
OutApp.Session.Logon
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
Else
.Attachments.Add ("\\Server\Pdf's\" & Range("G5").Value &
".pdf")
End If
.send
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 ")
Sheet1.Protect
End Sub

--
Corey ....
The Silliest Question is generally
the one i forgot to ask.


 
Reply With Quote
 
 
 
 
Nigel
Guest
Posts: n/a
 
      29th Sep 2008
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?



--

Regards,
Nigel
(E-Mail Removed)



"Corey" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I think i may have deleted a part of code ina module to now cause a
>Compile Error.
> 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")
> OutApp.Session.Logon
> 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
> Else
> .Attachments.Add ("\\Server\Pdf's\" & Range("G5").Value &
> ".pdf")
> End If
> .send
> 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 ")
> Sheet1.Protect
> End Sub
>
> --
> Corey ....
> The Silliest Question is generally
> the one i forgot to ask.
>


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error sending attachment glrosen@gmail.com Microsoft Outlook Discussion 0 23rd Aug 2007 05:27 PM
Sending email attachment causes error =?Utf-8?B?Q2Fyb2w=?= Microsoft Outlook Discussion 0 26th Jun 2007 04:27 PM
Sending mail with attachment error mfsurvey@bigpond.com Microsoft Outlook 1 12th Aug 2005 12:24 PM
Error msg when sending an email with attachment Thomas Lam Microsoft Outlook 2 27th Jul 2004 07:11 AM
Error sending attachment Brook Microsoft Outlook Discussion 0 24th Jun 2004 07:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:11 PM.