Programmatically load clipboard with hyperlink RRS feed

  • Question

  • (I hope this is an appropriate forum: please advise if not).

    I would like to be able to load the clipboard using VBA within Word (2003) ready for pasting into an Outlook e-mail (or another Word document).  I need to be able to set the link text separately (rather than just pasting the full URL/UNC target).

    I'm using fm20.dll and can successfully load plain text, but am starting to think it's not possible to load a hyperlink.

    I'm aware that HTML fragments can be handled in VB (for example) but the only tool available in the relevant environment is VBA.  (I'm also aware that it might be possible to generate 'bespoke' functions using standard APIs - but, again, that's not really an option here). 

    Any ideas?

    Sunday, October 9, 2011 10:23 AM

All replies

  • After pasting a plain text link into Word (typically Outlook's email editor) and typing a space or Enter the link is converted to a full hyperlink.

    If you have a reference to fm20.dll, simply add a userform to add the reference (can then remove the form), try this

    Sub test()
    Dim sLink As String
    Dim dObj As DataObject
            sLink = "www.mysite.com"
         Set dObj = New DataObject
         dObj.SetText sLink
    End Sub

    Run the code, paste into Word/email, type space or enter

    Peter Thornton

    Sunday, October 9, 2011 5:01 PM
  • Thanks, Peter - but I need the visible text to be different from the actual link address
    Sunday, October 9, 2011 7:47 PM