Results 1 to 10 of 10

UPDATED - Trying to Create a Hyperlink in VBA and Copy it to Clipboard

Threaded View

  1. #1
    Registered User
    Join Date
    09-08-2023
    Location
    Ontario, Canada
    MS-Off Ver
    Microsoft 365 Office
    Posts
    5

    UPDATED - Trying to Create a Hyperlink in VBA and Copy it to Clipboard

    I have built a UserForm to manage HyperLinks from one worksheet that are related to specific Items on another worksheet.
    To support this, I show a UserForm with a listbox containing the Hyperlinks related to the selected item.
    The Userform also contains: a button to add a new link, a button to delete a link, and a button to open a link.
    I am adding a button to copy a link (to the clipboard). I have built the hyperlink string and copied it to the clipboard.

    I could not post the full Sample String here ---> <a href="url">"Test link number 19"</a>
    but the "url" is properly formed

    I have pasted from the clipboard and the string (as shown above) is returned in both Notepad and Word.
    I am not a developer and feel like I am missing something that should be obvious (or I should have learned by now).
    Would very much appreciate a push in the right direction.

    Code:
    Private Sub CopyButton_Click()
    Dim CopyToClip As Object
    Dim LinkString As String
    Set CopyToClip = CreateObject("HtmlFile")
    LinkString = "<a href=" & Chr(34) & URLTxtBox & Chr(34) & ">" & Chr(34) & NameTxtBox & Chr(34) & "</a>"
    CopyToClip.ParentWindow.ClipboardData.SetData "text", LinkString
    End Sub
    Last edited by Him, just him; 09-11-2023 at 11:45 AM. Reason: Added detail

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 9
    Last Post: 06-20-2023, 04:58 AM
  2. [SOLVED] VBA loop through column and extract embedded hyperlink and create clickable hyperlink
    By Jay S. in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-26-2021, 04:42 PM
  3. Create string to copy to clipboard
    By her.rockstar in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 02-06-2019, 01:31 PM
  4. [SOLVED] Get a hyperlink onto clipboard?
    By terrypin in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 12-11-2017, 11:39 AM
  5. Replies: 3
    Last Post: 04-17-2017, 10:32 AM
  6. macro to move 1 cell left and paste CURRENT clipboard content as HYPERLINK
    By sgoesef in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-28-2013, 01:31 PM
  7. Replies: 3
    Last Post: 10-21-2011, 06:59 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1