5

Is it possible to create a quick part that autoreplaces a string with an hyperlink in Outlook 2010? I would like to avoid the vba used in the question Convert Plain Text to Hyperlink in Outlook .

Example

  • if I type (and press F3)

google something

  • It replaces it with the hyperlink

something

Which links to:

https://www.google.nl/?q=something#newwindow=1&q=something
spoorcc
  • 103

1 Answers1

1

You may avoid VBA and quick-parts by using AutoHotkey to create a shortcut macro that issues the keys that do the job.

But since you ask for an Outlook solution, here is a simple (and even somewhat tested) VBA macro to convert the currently selected text to a hyperlink of the type you requested:

Sub SelectionToHyperlink()
' Convert the current selection to a hyperlink
If ActiveInspector.EditorType = olEditorText Then
    MsgBox "Can't add links to textual mail"
    Exit Sub
End If
Dim doc As Object
Dim sel As Object
Set doc = ActiveInspector.WordEditor
Set sel = doc.Application.Selection
doc.Hyperlinks.Add Anchor:=sel.Range, _
    Address:="https://www.google.nl/?newwindow=1&q=" & sel.Text, _
    SubAddress:="", _
    ScreenTip:="", _
    TextToDisplay:=sel.Text
End Sub
harrymc
  • 498,455