I am trying to copy a pivot chart and paste it into a Lotus notes mail. I am getting some success (a new mail is opened and the contact is entered into the Send To box), the problem is the chart is not pasted and in it's place there is a line of the vba I am coding.
The code runs as follows:
Option Explicit
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Sub Lotus_Formatted_Range_Into_Body()
Dim oWorkSpace As Object, oUIDoc As Object
Dim stTo As String, stCC As String, stSubject As String, stBody As String
Dim chartBody As Object
Dim lnRetVal As Long
lnRetVal = FindWindow("NOTES", vbNullString)
If lnRetVal = 0 Then
MsgBox "Notes must be running in order to execute this procedure.", vbInformation, "Systemerror - Lotus Notus"
Exit Sub
End If
Application.ScreenUpdating = False
Set oWorkSpace = CreateObject("Notes.NotesUIWorkspace")
stTo = "alegg@dek.com"
stCC = ""
stSubject = "Subject of the Message"
'stBody = "This shows up in the Message Body"
On Error Resume Next
Set oUIDoc = oWorkSpace.ComposeDocument("NotesUK1/SERVERS/DEK", "mail\alegg.nsf", "Memo")
Set oUIDoc = oWorkSpace.CurrentDocument
Call oUIDoc.FieldSetText("EnterSendTo", stTo)
Call oUIDoc.FieldSetText("EnterCopyTo", stCC)
Call oUIDoc.FieldSetText("Subject", stSubject)
'Call oUIDoc.FieldSetText("Body", stBody)
Sheets("Part Nos By Month").Select
'In the active sheet a named range is used
Set chartBody = ActiveChart
ActiveChart.Copy
Call oUIDoc.GoToField("Body")
Call oUIDoc.Paste
Call oUIDoc.Send(False)
Call oUIDoc.Save(True, False, False)
Call oUIDoc.Close
Set oUIDoc = Nothing
With Application
.CutCopyMode = False
.ScreenUpdating = True
End With
MsgBox "The e-mail have been created, saved but not sent.", vbInformation
End Sub
Anyone got any ideas?
Appreciate any help!!!
The code runs as follows:
Option Explicit
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Sub Lotus_Formatted_Range_Into_Body()
Dim oWorkSpace As Object, oUIDoc As Object
Dim stTo As String, stCC As String, stSubject As String, stBody As String
Dim chartBody As Object
Dim lnRetVal As Long
lnRetVal = FindWindow("NOTES", vbNullString)
If lnRetVal = 0 Then
MsgBox "Notes must be running in order to execute this procedure.", vbInformation, "Systemerror - Lotus Notus"
Exit Sub
End If
Application.ScreenUpdating = False
Set oWorkSpace = CreateObject("Notes.NotesUIWorkspace")
stTo = "alegg@dek.com"
stCC = ""
stSubject = "Subject of the Message"
'stBody = "This shows up in the Message Body"
On Error Resume Next
Set oUIDoc = oWorkSpace.ComposeDocument("NotesUK1/SERVERS/DEK", "mail\alegg.nsf", "Memo")
Set oUIDoc = oWorkSpace.CurrentDocument
Call oUIDoc.FieldSetText("EnterSendTo", stTo)
Call oUIDoc.FieldSetText("EnterCopyTo", stCC)
Call oUIDoc.FieldSetText("Subject", stSubject)
'Call oUIDoc.FieldSetText("Body", stBody)
Sheets("Part Nos By Month").Select
'In the active sheet a named range is used
Set chartBody = ActiveChart
ActiveChart.Copy
Call oUIDoc.GoToField("Body")
Call oUIDoc.Paste
Call oUIDoc.Send(False)
Call oUIDoc.Save(True, False, False)
Call oUIDoc.Close
Set oUIDoc = Nothing
With Application
.CutCopyMode = False
.ScreenUpdating = True
End With
MsgBox "The e-mail have been created, saved but not sent.", vbInformation
End Sub
Anyone got any ideas?
Appreciate any help!!!