Jeanne said:
Trying to create a hyperlink/macro to an email address in a protected
form - I know how to create a hyperlink/macro so that it links to a
web page - but I don't know the command/code in visual basic to link
the hyperlink to an email address. Not sure if I have asked this
correctly.
Thank you,
The following macro shows how to insert the link. However, as long as the
document is protected, the link will be unusable -- clicking it won't do
anything at all.
Sub ProtectedDocMailLink()
Dim myRg As Range
Dim MailAddr As String
MailAddr = InputBox("Address:")
If Len(MailAddr) = 0 Then Exit Sub
With ActiveDocument
If .ProtectionType <> wdNoProtection Then
.Unprotect
End If
If .Bookmarks.Exists("mail") Then
Set myRg = .Bookmarks("mail").Range
.Hyperlinks.Add Anchor:=myRg, _
Address:="mailto:" & MailAddr, _
TextToDisplay:=MailAddr
End If
.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End With
End Sub
You will have much better results by using the built-in command File > Send
To > Mail Recipient (As Attachment), if that's what you want to do. (In Word
2007 this is Office button > Send > EMail.) You can add that command to a
toolbar (in Word 2007, the Quick Access Toolbar) in your form's template so
it will be readily available.
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.