PDA

View Full Version : Email Doc in Word 97 VBA?



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

belly0fdesir
06-20-2007, 09:22 AM
I'm thinking that maybe mailitem just isn't in the 97 library or something, but I wanted to see if someone here had more insight on it... If it simply can't be done, it'd be cool to know that too and I'll have to just find another way of handling these requests... thanks to anyone who can help :)

belly0fdesir
06-22-2007, 12:18 PM
:mkay well... i suppose there's just no way that this is going to work then... thank you to anyone who considered helping me... I appreciate the thought :yes I'll just have to think of another way to get this done i spose... :think: