I am creating a form in Word. My version of Office is 2010. I would like for this form to be on our website for many users to be able to use. (I will require that they have Word and Outlook, but cannot predict what version they have.) On this form, I have a Submit button that runs a macro to send the completed form via Outlook Email (as an attachment) to a given email address.
It runs fine on my machine. However, when I send it to my coworker who has Office 2007, the Outlook Object Library is not available, so it dies unable to find olMailItem. I cannot check the Object Library 12.0 in VB Editor, because I have 14.0. I would like for this to run simply.
Is there a way in my Word VBA Macro to make the Outlook Object Library available to this Macro? I will include my code for you to get a better idea of what I'm doing.
If I cannot open the object library through the macro, do you have a suggestion on how to accomplish this?
Thank you!!
Sheron
The Macro:
Private Sub CommandButton1_Click()Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document
On Error Resume Next
Application.ScreenUpdating = False
Set OL = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set OL = CreateObject("Outlook.Application")
End If
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
Doc.Save
With EmailItem
.Subject = "Go Grant Application"
.Body = "Please see the attached Go Grant Application." & vbCrLf & _
"This will be the next line in the message." & vbCrLf & _
"This will be the last line in the message."
.To = "sheronw@nhcconline.com"
.Importance = olImportanceNormal 'Or olImprotanceHigh Or olImprotanceLow
.Attachments.Add Doc.FullName
.Send
End With
Application.ScreenUpdating = True
Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing
End Sub
'Private Sub CommandButton1_Click()
'ActiveDocument.HasRoutingSlip = True
'With ActiveDocument.RoutingSlip
' .Subject = "Go Grant Application"
' .AddRecipient "sheronw@nhcconline.com"
' .Delivery = wdAllAtOnce
'End With
'ActiveDocument.Route
'End Sub