W
WP
Can you guys tell me why my code stops??
I have created a button on my form to email this doc after they save
it but when I click the email button its stops and highlights the
Private Const and says invalid attribute in sub or function
Private Sub CommandButton2_Click()
Private Const EMBED_ATTACHMENT As Integer = 1454
Private Sub SendMailWithAttachment()
Dim s As Object
Dim db As Object
Dim doc As Object
Dim rtItem As Object
Dim Server As String, Database As String
Dim strError As String
Screen.MousePointer = vbHourglass
'Here's the server name and database name
Server = "nsxx01"
Database = "nsxx01\xxwp.nsf"
' start up Lotus Notes and get object handle
Set s = CreateObject("Notes.NotesSession")
Set db = s.GETDATABASE(Server, Database)
On Error GoTo ErrorLogon
' See if user is logged on yet;
' if not, the error handler will
' kick in!
Set doc = db.CREATEDOCUMENT
On Error GoTo 0
doc.Form = "Memo"
'Send an EMail to myself
doc.SendTo = "xxwp@..."
doc.Subject = "Literature Request"
' this will build the text part of your mail message
Set rtItem = doc.CREATERICHTEXTITEM("Body")
Call rtItem.APPENDTEXT("A literature request")
Call rtItem.ADDNEWLINE(1)
'Attach a document!
Call rtItem.EmbedObject
(EMBED_ATTACHMENT, "", "T:\Docs\word\Litrequest.doc")
Call doc.SEND(False) 'Make sure this parameter stays false
' set all object handles to nothing to release memory
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
Screen.MousePointer = vbDefault
MsgBox "Mail has been sent!", vbInformation
Exit Sub
ErrorLogon:
If Err.Number = 7063 Then
MsgBox "Please login to Lotus Notes first!", vbCritical
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
Screen.MousePointer = vbDefault
Exit Sub
Else
strError = "An Error has occurred on your system:" & vbCrLf
strError = strError & "Err. Number: " & Err.Number & vbCrLf
strError = strError & "Description: " & Err.Description
MsgBox strError, vbCritical
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
Screen.MousePointer = vbDefault
Exit Sub
End If
UserForm1.Hide
End Sub
I have created a button on my form to email this doc after they save
it but when I click the email button its stops and highlights the
Private Const and says invalid attribute in sub or function
Private Sub CommandButton2_Click()
Private Const EMBED_ATTACHMENT As Integer = 1454
Private Sub SendMailWithAttachment()
Dim s As Object
Dim db As Object
Dim doc As Object
Dim rtItem As Object
Dim Server As String, Database As String
Dim strError As String
Screen.MousePointer = vbHourglass
'Here's the server name and database name
Server = "nsxx01"
Database = "nsxx01\xxwp.nsf"
' start up Lotus Notes and get object handle
Set s = CreateObject("Notes.NotesSession")
Set db = s.GETDATABASE(Server, Database)
On Error GoTo ErrorLogon
' See if user is logged on yet;
' if not, the error handler will
' kick in!
Set doc = db.CREATEDOCUMENT
On Error GoTo 0
doc.Form = "Memo"
'Send an EMail to myself
doc.SendTo = "xxwp@..."
doc.Subject = "Literature Request"
' this will build the text part of your mail message
Set rtItem = doc.CREATERICHTEXTITEM("Body")
Call rtItem.APPENDTEXT("A literature request")
Call rtItem.ADDNEWLINE(1)
'Attach a document!
Call rtItem.EmbedObject
(EMBED_ATTACHMENT, "", "T:\Docs\word\Litrequest.doc")
Call doc.SEND(False) 'Make sure this parameter stays false
' set all object handles to nothing to release memory
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
Screen.MousePointer = vbDefault
MsgBox "Mail has been sent!", vbInformation
Exit Sub
ErrorLogon:
If Err.Number = 7063 Then
MsgBox "Please login to Lotus Notes first!", vbCritical
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
Screen.MousePointer = vbDefault
Exit Sub
Else
strError = "An Error has occurred on your system:" & vbCrLf
strError = strError & "Err. Number: " & Err.Number & vbCrLf
strError = strError & "Description: " & Err.Description
MsgBox strError, vbCritical
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
Screen.MousePointer = vbDefault
Exit Sub
End If
UserForm1.Hide
End Sub