Hi Guys, I have a problem with a Macro which exports data from Excel to a Lotus Notes Memo. A friend at another company can run it perfectly. He uses Lotus Notes 6.5.4. and i use Lotus Notes 6. 0.1.We both have the same references within the code. We have the same code. We both have Lotus Domino Objects as a reference within Excel. However, when I run it, it says “Active X component can’t create object”, on the code line “Set session = New NotesSession”.Any ideas why? here’s all the code:
Dim session As NotesSession
Dim mailDb As NotesDatabase
Dim mailDoc As NotesDocument
Dim rtItem As NotesRichTextItem
Dim dbdir As NotesDbDirectory
Dim item As NotesItem
’ Notes
’ On Error GoTo ErrorHandler
’ NotesSession = Createoleobject
’ NotesSession.ConnectTONewObject (“Notes.Notesession”)
’ Set session = CreateObject(“Lotus.NotesSession”)
'Call session.Initialize 'This get a reference to Lotus Notes
’ TextUsername = session.UserName
'This initializes the referenct
Set session = New NotesSession 'This get a reference to Lotus Notes
session.Initialize 'This initializes the referenct
'This gets a reference to the DB Directory object, which is used to find your mail file (Notes Inbox)
'The value passed as the parameter is the full Notes server name. You can find this by going to your
'Notes Inbox, selecting File → Database → Properties. The Server Name is listed under the Title.
Set dbdir = session.GetDbDirectory(“GMISM201/GMI/HSBCMERIDIAN”)
Set mailDb = dbdir.OpenMailDatabase 'This opens your mail database so you can send a message.
With mailDb
If Not .IsOpen Then 'Checking to make sure the database is open
Call mailDb.Open 'If it’s not open then open it.
End If
Set mailDoc = .CreateDocument 'Create a new document
End With
With mailDoc
'Create a field call Form and assign the value of Memo. This makes the document an e-mail message.
Set item = .AppendItemValue(“Form”, “Memo”)
Call item.CopyItemToDocument(mailDoc, “Form”) 'Add the field to the document
'Create a field called sendTo and assign the value passed in via the sendTo variable.
Set item = .AppendItemValue(“sendTo”, sendTo) 'This is the mail to list
Call item.CopyItemToDocument(mailDoc, “sendTo”)
If Len(cc) > 0 Then
'Create a field called cc and assign the value passed in via the cc variable.
Set item = .AppendItemValue(“cc”, cc) 'This is the Carbon Copy list
Call item.CopyItemToDocument(mailDoc, “cc”)
End If
If Len(bcc) > 0 Then
'Create a field called bcc and assign the value passed in via the bcc variable.
Set item = .AppendItemValue(“bcc”, bcc) 'This is the Blind Carbon Copy list
Call item.CopyItemToDocument(mailDoc, “bcc”)
End If
If Len(subject) > 0 Then
'Create a field called subject and assign the value passed in via the subject variable.
Set item = .AppendItemValue(“subject”, subject) 'This is the subject of the e-mail
Call item.CopyItemToDocument(mailDoc, “subject”)
End If
'Create a field called Body
Set rtItem = .CreateRichTextItem(“Body”)
Call rtItem.AppendText(body) 'This is the text of the e-mail
Call .Send(False)
End With
SendMailMemo = True
ExitHere:
Set item = Nothing
Set rtItem = Nothing
Set mailDoc = Nothing
Set mailDb = Nothing
Set dbdir = Nothing
Set session = Nothing
Exit Function
ErrorHandler:
Call MsgBox("Error " & Err & ": " & Error & " occurred for " & sendTo & “.”, vbExclamation, “Messaging Error”)
SendMailMemo = False
Resume ExitHere
End Function