PDA

View Full Version : Hyperlink highlighted text



penfold1992
06-10-2014, 02:18 AM
Hello All,
I want to create a macro that essentially puts a web address on whatever text you highlight.


Sub Test()
Dim ObjItem As MailItem
Set ObjItem = Application.ActiveInspector.CurrentItem ' to target the current mail item
Dim Sel As Word.Selection
Set Sel = Application.ActiveInspector.WordEditor.Windows(1).Selection ' to target the selection

Dim URL As String
URL = 'url link that I cant post due to post restrictions'

Sel.Hyperlinks.Add Sel, URL

Set Oli = Nothing
Set Sel = Nothing

This doesnt work but it should be some useful pseudo code as to what I am trying to achieve.
Thanks in advance!

westconn1
06-10-2014, 03:42 AM
try
Sel.Hyperlinks.Add Sel.Range, URL

penfold1992
06-10-2014, 04:31 AM
try
Sel.Hyperlinks.Add Sel.Range, URL

absolute, PERFECTION, thank you so much!!!

I dont know if this is related to what I am trying to do or not but maybe it is so I will ask anyway...
When I open Outlook and click my button (which contains that macro...)
I get asked to enable macros. Is there any way in which I can bypass this so I do not have to keep clicking "Enable"?

westconn1
06-10-2014, 05:07 AM
change the macro security settings