Macro to email document

L

Lisa

Is there a way to email a protected word document through a vb macro.
Currently I have the macro below, but the user actually has to Ctrl / V to
paste the appropriate adress. I am using Word 2002 and Outlook 2000

WordBasic.ToolsUnprotectDocument DocumentPassword:="procedures"
WordBasic.EditBookmark Name:="date", SortBy:=0, GoTo:=1
WordBasic.CharLeft 1
WordBasic.CharRight 2
WordBasic.CharRight 9, 1
WordBasic.EditCopy
WordBasic.EditBookmark Name:="date", SortBy:=0, GoTo:=1
WordBasic.EditClear
WordBasic.EditBookmark Name:="date", SortBy:=0, Add:=1
WordBasic.EditPaste
WordBasic.EditBookmark Name:="Email", SortBy:=0, GoTo:=1
WordBasic.EditCopy
WordBasic.ToolsProtectDocument DocumentPassword:="procedures", NoReset:=1,
Type:=2
Button = WordBasic.MsgBox("This work order will be emailed to Policy
Services for processing. To complete the process hit OK and you will receive
your Outlook message hit Ctrl/V And it will paste the correct email address
for you. ", 0)
ActiveDocument.SendMail

Any assistance to make this process easier would be great. Thanks.
 
D

Doug Robbins - Word MVP

See the second method in the article "How to send an email from Word using
VBA" at:

http://www.word.mvps.org/FAQs/InterDev/SendMail.htm

On the assumption that the bookmark email is assigned to a formfield, you
can use

.To = ActiveDocument.Formfields("Email").Result

to get the email address to which the form is to be sent. Or, if it's just
bookmarked in the document

.To = ActiveDocument.Bookmarks("Email").Range.Text



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
L

Lisa

Where in the code should I put it and do I eliminate activedocument.sendMail.
Also the document is protected do I have to keep the unprotect statement to
grab the bookmark.

Thanks.
 
L

Lisa

here is the code I have now:

ActiveDocument.SendMail
..To = ActiveDocument.Bookmarks("Email1").Range.Text

and it is giving me an error Invalid or Unqualified reference...
when I look at the help it indicates I need a With statement.

Thanks again.
 
D

Doug Robbins - Word MVP

You will need to use the code in the article, not a combination of your code
and a bit of it.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top