+ Reply to Thread
Results 1 to 18 of 18

Retain Cookies when clicking Excel Links?

  1. #1
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Retain Cookies when clicking Excel Links?

    So I know the reason why cookies are not "retained" when you click an internal link in Excel (due to how it processes and redirects to the URL) but is there a work around?

    I have some links in a spreadsheet that opens a webpage that I use all day, but it prompts me to login, which I want to bypass. I know it is because Excel is sort of "bypassing" the cookies by using some function .dll or some such... but I am trying to find a work around.

    I found something online that I though would work but since my links are generated with =HYPERLINK formula it doesn't work. Hoping someone might have some ideas"

    This is the info I found online through Google
    Please Login or Register  to view this content.
    The problem is my links are generated with this code. (Actually I tested this with just a text hyperlink too and all it did was open an Explorer window)

    Please Login or Register  to view this content.
    All this is our company website, linking me to a search function we use but saving me 3 or 4 steps to get there when I am working in a spreadsheet with values I want to search for.


    Any ideas? Thanks in advance! - oh and the workaround has to be something not requiring admin access since this is all local, so I can't do registry edits or anything like that, it has to be within Excel (VBA or other)
    Last edited by NewYears1978; 04-05-2019 at 10:35 AM.

  2. #2
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Retain Cookies when clicking Excel Links?

    Untested random thought.

    Try deleting .TextToDisplay from the code.

  3. #3
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: Retain Cookies when clicking Excel Links?

    Striking out

  4. #4
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Retain Cookies when clicking Excel Links?

    Try changing the definition of strAddress to

    Please Login or Register  to view this content.
    Note that -1 assumes that the hyperlink associated with the cell A2 is in B2 (1 column to the left). All links must be defined in the code, not a formula. If they are all the same except for the cell reference A2 then this should work once you have it set up correctly. If the text part of the link is variable between rows then it could prove to be a pain to set up.

    You will also need to remove the formula from the sheet and create a fixed hyperlink by right clicking the cell, then inserting a link. The text to display can be whatever is required, but the link must point back to the cell that the link is in. i.e. a link in Sheet 1 cell B2 must point to Sheet 1 B2, nowhere else!

  5. #5
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: Retain Cookies when clicking Excel Links?

    Okay so I input the code
    Please Login or Register  to view this content.
    into the sheet I am using. I put just the text "Search" in B2, then edited the hyperlink and did the place in document linking back to B2.

    I can see what is supposed to happen, it opens explorer and should run the link through there (which works manually btw), however when I click the link it opens explorer but that's all that happens, did I miss a step? Thanks for your help by the way, much appreciated.
    Last edited by NewYears1978; 04-09-2019 at 11:27 AM.

  6. #6
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Retain Cookies when clicking Excel Links?

    Are you certain that the link created is 100% valid?

    I can't see that you've missed a step or done anything wrong from what you have said.

    I just tried the code from your last post, but replaced the web address in the string with the one for this thread and it worked fine.

    Does the link work for you if you try the same?

  7. #7
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: Retain Cookies when clicking Excel Links?

    Quote Originally Posted by jason.b75 View Post
    Are you certain that the link created is 100% valid?

    I can't see that you've missed a step or done anything wrong from what you have said.

    I just tried the code from your last post, but replaced the web address in the string with the one for this thread and it worked fine.

    Does the link work for you if you try the same?
    I think you're right, when I just put in http://www.google.com it then works..so it's something with the link I am using. Not sure though as that link seems to work manually. I will look into it.

    It's weird - if i just change the link without the cell reference part, it works in Chrome manually but won't work from within Excel

    Example:
    Please Login or Register  to view this content.
    It just opens explorer but doesn't run the link

    It works without the form commands
    Please Login or Register  to view this content.
    I will just have to work with it..maybe it will not work with form commands in it.

    Tried everything, the links work manually but not through excel if I add any of the & commands on it like:
    Please Login or Register  to view this content.
    They work manually through explorer just not through excel..very strange...
    Last edited by NewYears1978; 04-10-2019 at 09:41 AM.

  8. #8
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Retain Cookies when clicking Excel Links?

    Just been trying a few things, when I use your link with the full string, it is opening file explorer instead of internet explorer. This method is taking me to a login page on your website.

    Please Login or Register  to view this content.
    You will need to change the location of Chrome.exe to the correct file location on your pc. I think mine is default location, so if yours is the same then it may work without change.

  9. #9
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: Retain Cookies when clicking Excel Links?

    That worked, thanks so much man you rock!

    The only issue is I can't mass copy down the link cell as it doesn't do the Cell Reference in sequence (so if my link is referenced to B2, when copied down it makes them all B2) - oddly the links still work it just moves the cursor back to B2..but it still runs the link correctly strangely...
    Last edited by NewYears1978; 04-11-2019 at 10:13 AM.

  10. #10
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Retain Cookies when clicking Excel Links?

    This should fix that if it's an issue. The links will still all reference B2, but this will move the cursor back to the cell that was clicked.
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: Retain Cookies when clicking Excel Links?

    Perfect! You rock, I wanted to rep you 100x but it only let me rep you once

  12. #12
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: Retain Cookies when clicking Excel Links?

    This has been working fine now suddenly it's throwing a "Type Mismatch (Error 13) on the strAddress line.

    Seems to be a formatting issue but I haven't changed anything and I cannot figure it out - any ideas?

    Please Login or Register  to view this content.
    Error on this line

  13. #13
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Retain Cookies when clicking Excel Links?

    What is in the cell that forms the search term?

    Without the file to evaluate, the only thing that I can think of is that the content of that cell is causing the issue.

  14. #14
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: Retain Cookies when clicking Excel Links?

    Just the word Search

  15. #15
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Retain Cookies when clicking Excel Links?

    Copy the code from your file and paste it to the forum, unedited. It sounds like there is a slight error somewhere, maybe a critical character has been deleted when you changed the url text.

  16. #16
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: Retain Cookies when clicking Excel Links?

    I would paste my file but it has a ton of information about clients - so my apologies

    Here's what the spreadsheet looks like:
    Attachment 623320

    Here's the code:
    Please Login or Register  to view this content.
    If I save the document and close it, the FIRST time I click a link as long as it's the one matching the cell reference (so clicking Search in B2 for instance) works, but then it gives the type mismatch after that. I assume I have to match the cell reference every time (not sure why though as that worked before)

    The issue is creating a new reference every time I add a new line is very tedious (having to click edit hyperlink and change the cell reference)

    That's definitely the issue as I tested 3 lines with the proper reference..is there not way to copy cell references down with a table like you would a formula? It only copies the original cell reference when I use auto fill so all my lines reference B2
    Last edited by NewYears1978; 05-07-2019 at 11:36 AM.

  17. #17
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Retain Cookies when clicking Excel Links?

    You can't drag and have it change relatively, but this simple loop will do the job for you.

    Try deleting the line
    Please Login or Register  to view this content.
    Then select all of the cells in your sheet that contain hyperlinks and run this code.
    Please Login or Register  to view this content.
    If you need the cells with the links to vary dynamically as you add more data to the sheet, then you could try using the code above in a worksheet change event.

  18. #18
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: Retain Cookies when clicking Excel Links?

    Sweet - this should work I will try it out, thank you!

    Edit:
    Worked - thanks so much! Now I can organize it and make it work dynamically since I do reorder and add rows quite often, thanks so much.

    I slapped this code in and it seems to work perfect

    Please Login or Register  to view this content.
    Last edited by NewYears1978; 05-08-2019 at 11:18 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Delete links to external sources and retain formulas in cells.
    By sfraneta in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-07-2014, 03:27 PM
  2. Replies: 3
    Last Post: 04-14-2014, 09:01 AM
  3. Edit Links and still retain the cell comments
    By fodejimi in forum Excel General
    Replies: 1
    Last Post: 01-17-2014, 07:31 AM
  4. Save As HTML & Retain Links [About to Rage]
    By callumogrady in forum Excel General
    Replies: 2
    Last Post: 10-19-2013, 06:28 PM
  5. How to copy linked Excel and Word files and retain links
    By ashleynpeters1 in forum Excel General
    Replies: 7
    Last Post: 05-30-2013, 08:27 PM
  6. Replies: 0
    Last Post: 10-20-2007, 04:33 AM

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