I used the following code in excel 07 and 03 and it worked flawlessly. Now that I have switched over to Excel 2010, I am getting an error.
The error is: "Variable not defined"
On the line: Set Session = CreateObject("Notes.NotesSession")
Anyone know why Excel 2010 is not accepting this Macro?
The error is: "Variable not defined"
On the line: Set Session = CreateObject("Notes.NotesSession")
Anyone know why Excel 2010 is not accepting this Macro?
Code:
Option Explicit
Sub EmailNotes()
Dim objNotesSession As Object
Dim objNotesDb As Object
Dim objNotesDoc As Object
Dim vaRecipients As String
Dim r As Long
Dim Msg As String
On Error GoTo Error_Handling
Application.ScreenUpdating = False
Set [B]Session =[/B] CreateObject("Notes.NotesSession")
strServer = Session.GetEnvironmentString("MailServer", True)
strMailfile = Session.GetEnvironmentString("MailFile", True)
Set Db = Session.GETDATABASE(strServer, strMailfile)
' Set uiws = CreateObject("Notes.NotesUIWorkspace")
'
' If db.IsOpen = True Then
' 'Already open for mail
' Else
' db.OpenMail
' End If
For r = 9 To Range("AF65536").End(xlUp).Row
'Create the e-mail and add the attachment.
' Set objNotesDoc = objNotesDb.CREATEDOCUMENT
Msg = ""
Msg = Msg & Range("AK" & r) & "," & vbCrLf & vbCrLf
Msg = Msg & Range("AI" & r) & "." & vbCrLf & vbCrLf
Msg = Msg & "Thank you," & vbCrLf
Msg = Msg & "John Doe"
vaRecipients = Range("AF" & r)
CreateAndDisplayNotesEmail vaRecipients, Range("AJ" & r) & " Timecard ", Msg, ""
'increment for the next person
r = r + 22
Next
MsgBox ("The e-mails have successfully been distributed."), vbInformation
ExitSub:
'Release objects from memory.
Set Db = Nothing
Set Session = Nothing
Set uiws = Nothing
Exit Sub
Error_Handling:
MsgBox "Error number: " & Err.Number & vbNewLine & _
"Description: " & Err.Description, vbOKOnly
Resume ExitSub
End Sub