Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 276
Default Compile Error sending pdf as attachment

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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Compile Error sending pdf as attachment

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




"Corey" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
error sending email (as attachment) from within Excel 2000 Plasticgeek Excel Discussion (Misc queries) 0 December 17th 07 03:36 PM
Sending attachment from excel Arno Setting up and Configuration of Excel 0 May 5th 05 08:18 AM
Sending exel attachment Jay Excel Discussion (Misc queries) 3 January 19th 05 06:57 PM
Sending a spreadsheet as an attachment Ron de Bruin Excel Programming 2 September 11th 04 08:13 AM
Sending spreadsheet as attachment Todd Huttenstine Excel Programming 0 September 14th 03 01:36 AM


All times are GMT +1. The time now is 03:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"