Consulting

Results 1 to 5 of 5

Thread: keyboard shortcut to copy the url of a cell

  1. #1

    keyboard shortcut to copy the url of a cell

    Basically, I'd like to know whether keyboard shortcut exists which would copy the value of the hyperlink formula of a cell to cache (which then I can insert into browser). Since Excel first makes a check of the hyperlink apparently against a "Microsoft Office Protocol Discovery" and since my urls require some authorization information, the data passed to the browser differs from the original hyperlink.. And hence I'm asking whether a described keys combination exists to copy the hyperlink of a cell. Of course if you know how to make my urls be passed to browser unaltered, you'd do me a very great favour by sharing that knowledge ..

  2. #2
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Why don't you right-click the cell and select "Open Hyperlink", which should be located toward the bottom of the pop-up menu? The code for this is simply...

    [vba]YourCellHere.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True

    'example to work with the active cell...
    ActiveCell.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True[/vba]

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Are you famiiar with Webqueries in Excel ?

  4. #4
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    All your Keyboard shortcust can be found here http://www.thecodecage.com/blog/2009...ard-shortcuts/
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  5. #5
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    you can play around with these: One puts the Excel hyperlink address in to clipboard after some customization, the other just 'follows' the link after some customization

    The HL in the cell is just www.Google.com but I added "/webhp?complete=0&hl=en" to it before putting in clipboard or launching

    I just used the OnKey technique to assign macro launching keys


    Option Explicit
    
    'uses code 'borrowed from' www.cpearson.com/Excel/Clipboard.aspx
    
    Sub CaptureOn()
        Application.OnKey "+^%c", "URL2Clipboard"
        Application.OnKey "+^%l", "URL2Launch"
    End Sub
    
    
    Sub CaptureOff()
        Application.OnKey "+^%c"
        Application.OnKey "+^%l"
    End Sub
    
    
    Sub URL2Clipboard()
        Dim rCell As Range
        Dim sURL As String
        
        
        If Not TypeOf Selection Is Range Then Exit Sub
        
        Set rCell = Selection.Cells(1, 1)
        With rCell
            If .Hyperlinks.Count = 0 Then Exit Sub
            
            'https://www.google.com
            sURL = .Hyperlinks(1).Address
            
            'add some stuff
            sURL = sURL & "/webhp?complete=0&hl=en"
            
            If Not PutInClipboard(sURL) Then Exit Sub
            
            'just to see if it really put it on the clipboard
            rCell.Offset(2, 2).Select
            ActiveSheet.Paste
        End With
    End Sub
    
    
    Sub URL2Launch()
        Dim rCell As Range
        Dim sURL As String
        
        
        If Not TypeOf Selection Is Range Then Exit Sub
        
        Set rCell = Selection.Cells(1, 1)
        With rCell
            If .Hyperlinks.Count = 0 Then Exit Sub
            
            'https://www.google.com
            sURL = .Hyperlinks(1).Address
            
            'add some stuff
            sURL = sURL & "/webhp?complete=0&hl=en"
            
            'launch
            ThisWorkbook.FollowHyperlink Address:=sURL
        
        End With
    End Sub
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

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