belly0fdesir
06-19-2007, 03:54 PM
I have no training on VBA, but I'm trying to learn and I borrowed bits and pieces from here and there and came up with the code below that emails the document in question to a specific email address. The code works great for all of our 2003 users, but not for any of the users that are still using Office 97. Is there a way to make this work for Office 97?
Private Sub CommandButton1_Click()
start:
On Error GoTo duh
Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document
Dim STRbookmark2 As String
STRbookmark2 = ActiveDocument.FormFields("Text1").Range.Text
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olmailitem)
Set Doc = ActiveDocument
Doc.Save
With EmailItem
.Subject = STRbookmark2 & " - Document Request"
.Body = "Attached you will find my Document Request." & vbCrLf & _
"Please let me know if you have any questions at all." & vbCrLf & _
"Thank you!"
.To = "AN EMAIL ADDRESS"
.Importance = olImportanceHigh
.Attachments.Add Doc.FullName
.Send
End With
Application.ScreenUpdating = True
Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing
GoTo theend
duh:
Dim Msg2, Style2, Title2, Ctxt2, Response2, MyString2
Msg2 = "Something has gone wrong. Please verify that you have selected a destination at the top of the screen and try again. Contact Donald Shaw if you the problem persists." ' Define message.
Style2 = vbOK
Title2 = "Oops!"
Ctxt2 = 1000
Response2 = MsgBox(Msg2, Style2, Title2)
If Response2 = vbOK Then
GoTo theend
End If
theend:
End Sub
Private Sub CommandButton1_Click()
start:
On Error GoTo duh
Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document
Dim STRbookmark2 As String
STRbookmark2 = ActiveDocument.FormFields("Text1").Range.Text
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olmailitem)
Set Doc = ActiveDocument
Doc.Save
With EmailItem
.Subject = STRbookmark2 & " - Document Request"
.Body = "Attached you will find my Document Request." & vbCrLf & _
"Please let me know if you have any questions at all." & vbCrLf & _
"Thank you!"
.To = "AN EMAIL ADDRESS"
.Importance = olImportanceHigh
.Attachments.Add Doc.FullName
.Send
End With
Application.ScreenUpdating = True
Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing
GoTo theend
duh:
Dim Msg2, Style2, Title2, Ctxt2, Response2, MyString2
Msg2 = "Something has gone wrong. Please verify that you have selected a destination at the top of the screen and try again. Contact Donald Shaw if you the problem persists." ' Define message.
Style2 = vbOK
Title2 = "Oops!"
Ctxt2 = 1000
Response2 = MsgBox(Msg2, Style2, Title2)
If Response2 = vbOK Then
GoTo theend
End If
theend:
End Sub