O
OptimumOrgs
I have created an MS Word 2002 template that uses the AutoClose macro to pop
up a user form with some buttons on it. The buttons run various
user-form-based VB code subroutines, one of which sends the document as an
attachment using the SendForReview method (the only method I could find in
Word that let me set the To: address and Subject line - code attached below).
It works fine, and Outlook sends the message okay, but sometime later,
apparently disconnected from anything I'm doing, Word pops up the above error
message in a dialogue box with just an OK button. I don't even know where to
start looking for this one - if I close Word first and then re-start it
later, the message shows up shortly after launch. I would appreciate any
hints or clues about what the heck is going on here (and would LOVE an
answer). Could it have something to do with the fact that I am manually
moving the sent e-mails to another folder after they are sent?
Here's the code, with my customer's identifying info removed:
Private Sub ButtonSubmit_Click()
Dim iResult As Integer ' Function result
Dim stEmailAddress As String ' E-mail Address to route this
request to
Dim stSubject As String ' E-mail Subject line
Dim x As String ' temporary string
'
' Close the user form that sent us here.
'
Unload Me
'
' Get the application name from the form field, append it to the subject
line,
' and set the e-mail address.
'
With ActiveDocument
x = .FormFields("SoftwareApplication").Result
stSubject = "MIS Request:" & x
stEmailAddress = "(e-mail address removed)"
'
' Mark the document with a custom property so this code doesn't run
again after submission.
'
.CustomDocumentProperties.Add _
Name:="zMISRequestSent", _
LinkToContent:=False, _
Value:=True, _
Type:=msoPropertyTypeBoolean
'
' Remove the document form protection so it can be edited on the
receiving end.
'
.Unprotect
'
' Turn on document change tracking.
'
.TrackRevisions = True
'
' Save this docoument, if altered.
'
If .Saved = False Then
.Save
End If
'
' The SendForReview function is used because in Word 2002 & 2003,
the only method available
' to send an e-mail and specify the subject is this one - the
SendMail Method forces the
' user to fill it in after a window opens containing the e-mail.
'
.SendForReview _
Recipients:=stEmailAddress, _
Subject:=stSubject, _
ShowMessage:=False, _
IncludeAttachment:=True
'
' Tell them it worked.
'
iResult = MsgBox(Prompt:="Document Successfully Sent to E-mail
Program", _
Buttons:=vbOKOnly + vbInformation, _
Title:="Action Completed")
End With
End Sub
up a user form with some buttons on it. The buttons run various
user-form-based VB code subroutines, one of which sends the document as an
attachment using the SendForReview method (the only method I could find in
Word that let me set the To: address and Subject line - code attached below).
It works fine, and Outlook sends the message okay, but sometime later,
apparently disconnected from anything I'm doing, Word pops up the above error
message in a dialogue box with just an OK button. I don't even know where to
start looking for this one - if I close Word first and then re-start it
later, the message shows up shortly after launch. I would appreciate any
hints or clues about what the heck is going on here (and would LOVE an
answer). Could it have something to do with the fact that I am manually
moving the sent e-mails to another folder after they are sent?
Here's the code, with my customer's identifying info removed:
Private Sub ButtonSubmit_Click()
Dim iResult As Integer ' Function result
Dim stEmailAddress As String ' E-mail Address to route this
request to
Dim stSubject As String ' E-mail Subject line
Dim x As String ' temporary string
'
' Close the user form that sent us here.
'
Unload Me
'
' Get the application name from the form field, append it to the subject
line,
' and set the e-mail address.
'
With ActiveDocument
x = .FormFields("SoftwareApplication").Result
stSubject = "MIS Request:" & x
stEmailAddress = "(e-mail address removed)"
'
' Mark the document with a custom property so this code doesn't run
again after submission.
'
.CustomDocumentProperties.Add _
Name:="zMISRequestSent", _
LinkToContent:=False, _
Value:=True, _
Type:=msoPropertyTypeBoolean
'
' Remove the document form protection so it can be edited on the
receiving end.
'
.Unprotect
'
' Turn on document change tracking.
'
.TrackRevisions = True
'
' Save this docoument, if altered.
'
If .Saved = False Then
.Save
End If
'
' The SendForReview function is used because in Word 2002 & 2003,
the only method available
' to send an e-mail and specify the subject is this one - the
SendMail Method forces the
' user to fill it in after a window opens containing the e-mail.
'
.SendForReview _
Recipients:=stEmailAddress, _
Subject:=stSubject, _
ShowMessage:=False, _
IncludeAttachment:=True
'
' Tell them it worked.
'
iResult = MsgBox(Prompt:="Document Successfully Sent to E-mail
Program", _
Buttons:=vbOKOnly + vbInformation, _
Title:="Action Completed")
End With
End Sub