Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return email button to originator?

Status
Not open for further replies.

Ian455

Instructor
Feb 8, 2006
3
GB
I am trying to insert a button to a Microsoft Word 2000 form template, so that once I have sent the form by email and the recipient has entered their information, that they click the button and the form comes back to me with that info inserted.
Nothing works, and my knowledge of Visual Basic is limited.
Please help.
Regards

Ian G
 
I use this on an excel button. I expect it would work with Word.

Code:
Sub ReturnByEmail()
Dim Msg, Style, Title, Help, Ctxt, Response, ReturnAddress       'define variables

ReturnAddress = "xxxx@xxxxx.xx.xx"

Msg = "Send completed forecasts to xxxxx? N.B. you may wish to foward a copy to your line manager."
Style = vbYesNo + vbCritical + vbDefaultButton2    ' Define buttons.
Title = "Monthly Monitoring Return" + " " + ThisWorkbook.Name   ' Define title.
Response = MsgBox(Msg, Style, Title)

If Response = vbYes Then    ' User chose Yes - email will be sent.

        On Error GoTo ErrorHandler         'need to trap invalid email addresses or other mail failure
        ActiveWorkbook.SendMail Recipients:=ReturnAddress, Subject:=Title, RETURNRECEIPT:=True
        On Error GoTo 0
        
        Msg = "Your email has been sent - and should appear in Outlook, Sent Items"
        Style = vbOK + vbDefaultButton1    ' Define buttons.
        Title = "Monthly Monitoring Return" + " " + ThisWorkbook.Name   ' Define title.
        Response = MsgBox(Msg, Style, Title)
Else    ' User chose No.
    
End If
Exit Sub
    
ErrorHandler:
      Msg = "Mail failure -  is your mailbox too full?   Try sending an email directly from outlook to " + ReturnAddress + " before reporting the fault"
      Style = vbOK + vbDefaultButton1    ' Define buttons.
      Title = "Monthly Monitoring Return" + " " + ThisWorkbook.Name   ' Define title.
      Response = MsgBox(Msg, Style, Title)

End Sub


Gavin
 
I have tried to but this in my word form and I keep getting the mail failure - is your mailbox too full msg. Can you please tell me what I'm doing wrong Thank you Irene
 
Try:
1. sending the form manually with macro recorder on. Does it work? What code do you get?

2.Commenting out the "On Error GoTo ErrorHandler" statement. The code will fail but what error message do you get?

What mail application are you using?

My knowledge of Word macros is very limited so if anyone else wants to chip in... Also you could do better posting the code you have and what you have tried in the VBA forum: Forum707


Gavin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top