Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2005

Tip: Looking for answers? Try searching our database.

Adding a button to Automaticaly E-mail a Word Document?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Neil - 06 Apr 2005 15:01 GMT
Hi there,

im want to make a word document with fields for users to fill out, then
press a button at the bottom, and the document will email to a specified
email address' (within the programming) and then close the document. - the
document will be opened from an email.

if anyone can tell me how to achieve this, that would be great,

thanks,

Neil
Chuck - 06 Apr 2005 16:01 GMT
Create your button on your document, double click on it to bring up the VBE
and in the CommandButton_Click event use the following

Private Sub CommandButton1_Click()

 'Erase any previous routing info
 ActiveDocument.HasRoutingSlip = False
 
 'Set new routing info
 ActiveDocument.HasRoutingSlip = True
 With ActiveDocument.RoutingSlip
     .Reset
     .AddRecipient Recipient:="youremail@address.com"
     .Message = "Your message here"
     .ReturnWhenDone = False
     .Delivery = wdAllAtOnce
 End With
 ActiveDocument.Route

End Sub

> Hi there,
>
[quoted text clipped - 8 lines]
>
> Neil
Neil - 06 Apr 2005 16:15 GMT
Hi chuck,

thanks for your reply - ive tried adding the code to a button in my
document, but it is giving me a message advising it is trying to access
contacts in my address book - which i dont think i want it to do, i just want
it to send to my specified address (which i specified) - when i click cancel,
it then has a run time error.

any ideas?

many thanks,

Neil

> Create your button on your document, double click on it to bring up the VBE
> and in the CommandButton_Click event use the following
[quoted text clipped - 29 lines]
> >
> > Neil
Chuck - 06 Apr 2005 17:43 GMT
It's not trying to access your address book because the address is hard coded
in the code (whatever you put in for "youremail@address.com").  Note that the
dialog you get says "if this is unexpected it may be a virus ...".  Of course
it's not unexpected -- it's in the code you've run.

The alternative would be to use ActiveDocument.SendMail but I don't know of
a way to get the email address into the To field of the mail message without
using SendKeys, but I've tried it and SendKeys doesn't seem to work in this
scenario (at least in Word2000 and Outlook2000).  

So unless someone else has a suggestion you may have to live with the
security warning you get with Route or else have the user supply the email
address using SendMail.

> Hi chuck,
>
[quoted text clipped - 43 lines]
> > >
> > > Neil
Chuck - 06 Apr 2005 17:59 GMT
I should have said _it doesn't matter if_ it's trying to access your address
book...

> Hi chuck,
>
[quoted text clipped - 43 lines]
> > >
> > > Neil
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.