EliseFreedman
Programmer
HI There
For a few weeks now, we have been using an excel form which users fill in and then click a submit button which automatically emails the completed form to us. Until now this has worked perfectly. However, I am now running into problems as we are in the midst of an upgrade to Office 2010. Some users are still using Office 2003. When they try to send the email they are getting an error as it is looking for the outlook14 object library.
I googled a bit and tried changing my code to use late binding. However, I am getting an error message when I run the code. The code works fine until it gets to the .To line when it says Run Time error 438 object does not support this method.
Can anyone help
For a few weeks now, we have been using an excel form which users fill in and then click a submit button which automatically emails the completed form to us. Until now this has worked perfectly. However, I am now running into problems as we are in the midst of an upgrade to Office 2010. Some users are still using Office 2003. When they try to send the email they are getting an error as it is looking for the outlook14 object library.
I googled a bit and tried changing my code to use late binding. However, I am getting an error message when I run the code. The code works fine until it gets to the .To line when it says Run Time error 438 object does not support this method.
Can anyone help
Code:
Sub Outlookmessage()
Const OLMAILITEM = 3 ' Outlook VBA constant olMailItem
Dim OutlookApp As Object
Dim MyItem As Object
Dim EmailAddr As String
Dim ccAddress As String
Dim Subj As String
Dim Sender As String
Dim Msg As String
Set OutlookApp = CreateObject("Outlook.Application")
Set MyItem = OutlookApp.CreateItem(OLMAILITEM)
EmailAddr = "elise.freedman@baesystems.com"
'ccAddress = UserForm1.Label2.Caption
Subj = "SHE Improvement Suggestion"
Msg = "Please find attached a SHE Improvement Suggestion" & vbCrLf & vbCrLf
With MyItem
.To = EmailAddr
.Subject = Subj
.Body = Msg
.Attachments.Add myfile2
.Attachments.Add myfile
.Send
End With
End If
End If