Signature macro

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

I have worked out a signature macro, but there is one small annoyance with
it. It does not underline the email address. If you enter an email address
directly into a document, Word can recognise it as an email address. But
running this macro does not underline it.

Any suggestions, or is this just a genuine "feature"?


Selection.Font.Bold = wdToggle
Selection.TypeText Text:="Firstname Lastname"
Selection.TypeParagraph
Selection.Font.Bold = wdToggle
Selection.Font.Size = 8
Selection.TypeText Text:="Email: (e-mail address removed) "
Selection.TypeParagraph
Selection.Font.Size = 12
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLowerBin
.OtherPagesTray = wdPrinterUpperBin
End With
End Sub
 
You need to format the address with the Hyperlink Style rather than use
direct formatting.

--
Terry Farrell - Word MVP
http://word.mvps.org/

:I have worked out a signature macro, but there is one small annoyance with
: it. It does not underline the email address. If you enter an email address
: directly into a document, Word can recognise it as an email address. But
: running this macro does not underline it.
:
: Any suggestions, or is this just a genuine "feature"?
:
:
: Selection.Font.Bold = wdToggle
: Selection.TypeText Text:="Firstname Lastname"
: Selection.TypeParagraph
: Selection.Font.Bold = wdToggle
: Selection.Font.Size = 8
: Selection.TypeText Text:="Email: (e-mail address removed) "
: Selection.TypeParagraph
: Selection.Font.Size = 12
: With ActiveDocument.PageSetup
: .FirstPageTray = wdPrinterLowerBin
: .OtherPagesTray = wdPrinterUpperBin
: End With
: End Sub
:
:
:
 
Brian,

You are observing one of the drawbacks of recording macros. Sometimes
what you get is not what you expect. You can create your signature
text with the hyperlink using ranges something like this:


Sub Signature()
Dim myRange As Range
Set myRange = Selection.Range

With myRange
.Text = "FirstName LastName" & vbCr
.Font.Bold = True
.Collapse wdCollapseEnd
.Text = "Email: "
.Font.Bold = False
.Font.Size = 8
.Collapse wdCollapseEnd
.Hyperlinks.Add myRange, "(e-mail address removed)"
.Expand wdSentence
.Font.Size = 8
.Collapse wdCollapseEnd
.Text = vbCr
.Collapse wdCollapseEnd
.MoveEnd wdParagraph, 1
.Font.Size = 12
.MoveEnd wdCharacter, -1
.Select
End With
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLowerBin
.OtherPagesTray = wdPrinterUpperBin
End With

End Sub

However, a more useful methdo might be to simply format your signature
text like you want it, select it, press Alt+F3 and create a AutoText
entery. Call it signedbrian and when you want to sign off just type
sign.. and when the autocomplete tip fires press enter.
 
Use:

Dim myrange As Range
Set myrange = Selection.Range
myrange.Hyperlinks.Add Anchor:=myrange, Address:[email protected]

In the code, the email address needs to be enclosed in quotes - the email
program automatically strips them off and converts the address.
--
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
 
Many thanks for all the replies.

Doug Robbins said:
Use:

Dim myrange As Range
Set myrange = Selection.Range
myrange.Hyperlinks.Add Anchor:=myrange, Address:[email protected]

In the code, the email address needs to be enclosed in quotes - the email
program automatically strips them off and converts the address.
--
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
 
Back
Top