Hi All.
I am trying to do this:
I have a form that has fields for users to fill in.
At the bottom of the document is a SEND button.
What I need to have happen is...
1. When the user clicks the SEND button, the current document (my form) is attached to an email message;
2. My address is already in the To Field;
3. 'MY Form Return' is in the Subject line;
4. and the email is then sent to me.
The code that I have so far is:
Private Sub Send1_Click()
Set objOutlook = CreateObject("Outlook.Application"
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add("me @ myddress.com"
Set objOutlookAttach = .Attachments.Add("C:\Documents and Settings\UserFolder\Desktop\Email From WordDoc\My Form.doc"
objOutlookRecip.Type = olTo
.Subject = "My Form Return"
.Body = "This is an automailer response from My Form.doc"
.Send
End With
End Sub
I know little about using VBA in Word. In Excel I can hold my own well enough, but this one is beyond me.
I have set up my VBA Object Libraries.
I cannot seem to get the active document to attach - which is what I would like to have happen.
The code above reflects changes made to send the attachment once it is saved...but I do not want the user to have to save the form - just fill it out and hit the button. I also do not want them to have to enter the address.
I also realize that this code ASSUMES that the user will have Outlook as an email client. Is there another way to leave the email client unspecified and have this work in some other program as well?
Anyway, I will go with my assumptions of Outlook as the client for now just to get some progress on this (because I am not making any on my own now...LOL!!)
Yes they will have MS Word.
This is (hopefully) supposed to work in Word 2K and 2K2 - I do not think that I will need to consider '97 at this time.
Windows versions would be '98, and above.
I think that this covers it.
Thank you very much for having a look!
I appreciate your help if you have any to offer!
Regards,
ViperGTS
I am trying to do this:
I have a form that has fields for users to fill in.
At the bottom of the document is a SEND button.
What I need to have happen is...
1. When the user clicks the SEND button, the current document (my form) is attached to an email message;
2. My address is already in the To Field;
3. 'MY Form Return' is in the Subject line;
4. and the email is then sent to me.
The code that I have so far is:
Private Sub Send1_Click()
Set objOutlook = CreateObject("Outlook.Application"
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add("me @ myddress.com"
Set objOutlookAttach = .Attachments.Add("C:\Documents and Settings\UserFolder\Desktop\Email From WordDoc\My Form.doc"
objOutlookRecip.Type = olTo
.Subject = "My Form Return"
.Body = "This is an automailer response from My Form.doc"
.Send
End With
End Sub
I know little about using VBA in Word. In Excel I can hold my own well enough, but this one is beyond me.
I have set up my VBA Object Libraries.
I cannot seem to get the active document to attach - which is what I would like to have happen.
The code above reflects changes made to send the attachment once it is saved...but I do not want the user to have to save the form - just fill it out and hit the button. I also do not want them to have to enter the address.
I also realize that this code ASSUMES that the user will have Outlook as an email client. Is there another way to leave the email client unspecified and have this work in some other program as well?
Anyway, I will go with my assumptions of Outlook as the client for now just to get some progress on this (because I am not making any on my own now...LOL!!)
Yes they will have MS Word.
This is (hopefully) supposed to work in Word 2K and 2K2 - I do not think that I will need to consider '97 at this time.
Windows versions would be '98, and above.
I think that this covers it.
Thank you very much for having a look!
I appreciate your help if you have any to offer!
Regards,
ViperGTS