40

I've got a hyperlink in an Excel 2013 sheet that links to an internal website. When I right click and select "edit hyperlink", I see this in the address bar (which is correct):

https://myserver.company.com/home/default.html#article?id=1203291003

However, when I left click, middle click, or right click -> open hyperlink I get the same behavior: IE11 opens and I get a http 404 error because the link (shown below) is not found.

https://myserver.company.com/home/default.html%20-%20article?id=1203291003

What could be converting the # to %20-%20? This is very odd because %20 is a space and there are no spaces in the URL.

Machavity
  • 30,841
  • 27
  • 92
  • 100
Greg Ruhl
  • 1,060
  • 2
  • 9
  • 27
  • Refer to closely related question on Super User, [MS Word 2013 - Hyperlinks with anchor tags (aka hash tags, bookmark tags) to external html files](http://superuser.com/questions/596414/ms-word-2013-hyperlinks-with-anchor-tags-aka-hash-tags-bookmark-tags-to-ext). – JohnC Sep 20 '16 at 12:53
  • This applies to PowerPoint 2007, Word 2007 and Excel 2007, too. – Christian Nov 25 '16 at 15:26
  • 2
    I think I found a solution for MS word 2010 and IE 11. If I change the default browser to Google Chrome and then change it back to IE 11, then it starts working. The root cause is that by defult on some computers this registry key does not exist HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Shell\Associations\URLAssociations\(http|https)\UserChoice and by changing default browser to Chrome we force windows to create it. – Zlelik Jun 07 '18 at 12:55

15 Answers15

24

This is a known issue with MS Excel. Basically, the hash/pound (#) sign is a valid character to use in a file name but is not accepted in hyperlinks in Office documents. The conversion to %20-%20 appears to be by design.

However, take a look at this question, highlighting the same issue but with Excel 2010:

which seems to imply it might be a browser issue with IE. If you can set another browser as your default, even temporarily for testing, it might work.

Community
  • 1
  • 1
djikay
  • 10,450
  • 8
  • 41
  • 52
  • 3
    Switched from Chrome as default browser to IE and it worked. Seems unusual as to why this would not affect IE but does affect non-MS browsers. – csharpforevermore May 21 '15 at 09:03
  • @ForTheWatch Which OS and which version of IE? – Johnny Utahh Jun 23 '15 at 21:15
  • That was for Windows 8.1, IE 11.0.9600.* and Excel 2013. – csharpforevermore Jun 24 '15 at 21:43
  • 1
    Not working for me with Chrome as browser. It seems ForTheWatch's comment says the exact opposite of what this answer says and is consistent with my result. Would rather not switch to IE if I can avoid it, and I would prefer a browser agnostic solution. – PatentWookiee Dec 09 '16 at 17:57
  • 1
    Not working for me either - and I'm going from MS Word to Chrome as default browser. It's not an IE issue. The issue is somehow, the URL I supplied to MS Word is being mangled with # being replaced with ' - ' (the %20 is a space). Yet another annoying MS Mystery. – QA Collective Nov 15 '17 at 23:55
  • 2
    This solution doesn't work if you must pass the document to another person. – Luke Feb 01 '18 at 09:14
  • This is NOT a browser issue! If you hover the mouse over the hyperlink in excel you will notice the # is already changed before you even click the link. – Maxter Aug 23 '18 at 13:06
10

I believe this might be of help to some people so i said id post it: I had the same problem with Word and as a work around i used a URL Encoder Do a quick search for one there's plenty such as here :

http://www.w3schools.com/tags/ref_urlencode.asp

Simply paste the url ,it will give back the Url that will work in a hyperlink from Word Excel etc.

Wolfie
  • 27,562
  • 7
  • 28
  • 55
kelevra88
  • 1,532
  • 3
  • 17
  • 25
  • also works for word, naturally – John-M Feb 24 '16 at 16:06
  • Had the problem in Word and this worked a treat. Cheers @kelevra88 – James Cushing Sep 29 '16 at 12:20
  • Any URL encoder should work. – Donald Byrd Jul 05 '17 at 18:35
  • 1
    But then the link does not work anymore. The whole point of the hash sign inside the link was to mark it as an anchor inside the file, not as part of the file location. For example if I access example.com/myfile#mysection then it works. But if I try to access example.com/myfile%23mysection then I get error 404, since no file exists with the name myfile#mysection. The point of the hash is for the browser to load example.com/myfile and then inside myfile to navigate to the anchor called "mysection". This technique is mostly used for implementing client-side (javascript) routing for SinglePageApp – Sorin Postelnicu Feb 01 '18 at 13:40
  • 1
    Excel is buggy if it removes the hash from a link, because the hash inside the link is part of normal W3 standards: http://w3.org/TR/html4/intro/intro.html#fragment-uri – Sorin Postelnicu Feb 01 '18 at 13:51
  • Does not work, `#` is `%23` in the browser URL that is opened, but I need it to be `#`, no `%23`. The site I am redirecting to just does not work with `%23` in the URL. – Dmitriy Popov Dec 23 '20 at 19:56
3

This seems to be IE specific, on Chrome the URL works correctly.

However I found adding ENCODEURL() fixed the issue for me.

Original version:

=IFERROR(HYPERLINK(VLOOKUP(B12,Table1,13,0),"Click Me"),"")

Fixed version:

=IFERROR(HYPERLINK(ENCODEURL(VLOOKUP(B12,Table1,13,0)),"Click Me"),"")
freedomn-m
  • 27,664
  • 8
  • 35
  • 57
lcheetha
  • 68
  • 6
  • Which version of Excel do you need for the ENCODEURL function? – Sorin Postelnicu Feb 01 '18 at 13:45
  • 1
    @SorinPostelnicu, ENCODEURL is available in Excel 2013 and 2016 for Windows. It is not currently available in Excel for Mac or Excel Online. – richardtallent Aug 20 '18 at 21:16
  • 1
    @richardtallent thanks for the info. This explains why I don't have it: because at the office we have Excel 2010. Plus, the purpose of our project is to export it in an Excel format which is cross-compatible to any OS and version. ;) – Sorin Postelnicu Aug 22 '18 at 08:36
  • This is great solution. I need to just add that ENCODEURL replaces also some letters, e.g Ł, ą, Ó. it's redundant in this case. I covered all desired letters' reverse conversion with nested SUBSTITUTE formulas – gangus Dec 02 '20 at 11:54
2

There is a workaround:

Change the default value "htmlfile" of HKEY_CLASSES_ROOT.htm key by another value, i.e "IEhtml".

This answer is based on the following article and worked for me in MS Escel 2010: http://answers.microsoft.com/en-us/office/forum/office_2013_release-word/word-2013-hyperlink-converting-to-20-20/4e8a2e8d-b889-4c77-8276-551b11e296d4

Daniel
  • 2,343
  • 2
  • 20
  • 24
  • Changing the default browser to Chrome and back to IE was a method of managing this at the office. – twip Oct 15 '14 at 16:14
1

I was able to get around this by using %23 in place of the # (hashtag|pound sign). My URL's now work within Excel 2013. The 'hovertext' shows the # symbol in the URL, but editing the link shows the %23.

http://www.example.com/page#location does not work

http://www.example.com/page%23location works

JRHelgeson
  • 53
  • 2
1

Workaround: Save as PDF

If for clients, read-only & don't need it in excel/Word format you could save file as a PDF. hyperlinks with "#" will work in PDF readers. Eg: http://help.overdrive.com/#videos?ade

0

This did not work for the machines I tried it on. The item below or process change on my end corrected the problem.

In MS Word hyperlinks, # becomes %. This is what is happening to me while running IE 11 on 64Bit Win7 OS. Word documents with hyperlinks that have the # symbols are causing the problem I believe.

Try a hyperlink from a word document that fails with error 404 like the following: http://iservice.prv/eng/imit/catalogue/software_application_service.shtml#outlook_text

Now change the # symbol near the end to a / then the hyperlink opens in IE 11 from a word document as expected like the corrected hyperlink below. http://iservice.prv/eng/imit/catalogue/software_application_service.shtml/outlook_text

When we are using the self-serve site and its content for support spec updates, make sure you change any links with # in them to / slashes before using/coping the link as an embedded hyperlink in the support spec word doc.

bundy
  • 1
0

In Excel 2013, you can use the encodeurl(url) function.

Example

Source: http://versitas.com/blog/two-easy-ways-to-encode-urls-in-excel/

You can then pass the encoded URL to the hyperlink(link_location,[friendly_name]) function to display a more readable URL.

Michael
  • 68
  • 7
0

I pasted the report into a new message in Outlook and the hyperlinks worked fine. It did not work when pasting into Word, nor did pasting them back into Excel from Outlook. (Using Office Professional Plus 2010 for all three apps).

I later followed the suggestion above regarding default browser. I went into Chrome and made it my default. Then closed Chrome. Then went into IE and made it my default. No reboot. Links worked.

Phill
  • 3
  • 1
Phill
  • 1
  • It looks like you may have accidentally made an edit from a different account. I've rejected the edit because it significantly changed the content of the post and I can't be *sure* it is from the same person. Please see [this section](http://stackoverflow.com/help/merging-accounts) of the help center to see how to merge your accounts if you're interested. In the meantime, you can log onto the original account that made this post and approve the edit yourself. – skrrgwasme Nov 09 '15 at 23:07
0

I had one user who could not open linked websites containing a # in the URL using IE. She could open with Chrome and Firefox. Others could open with IE, Chrome and Firefox.

I investigated the http_user_agent value my version and found this: HTTP_USER_AGENT=Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3)

I found her version to have this value:

HTTP_USER_AGENT=Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)

The key phrase is compatible; MSIE 10.0 (mine reads compatible; MSIE 7.0). When I opened IE Developer Tools, I discovered that the default Document Standards setting in my browser was IE7 Standards. The default setting in her browser was IE10 Standards. When she changed her document settings to IE7 Standards, closed the browser and then clicked the link from Excel, the page opened correctly in IE.

In our corporate environment, we use IE as the default browser, and we have Compatibility View turned on by default, but somehow her settings had been changed. It does give fair warning that in the future the hash (#) might be problematic in a URL.

0

Whenever Excel sees a '#' sign in a hyperlink, it tries to interpret it as sort of a relative reference or a 'magic hash'. See this: http://www.myonlinetraininghub.com/excel-factor-18-dynamic-hyperlinks-and-the-magic

But this is bad if your hyperlink has a '#' sign in it without you intending to use this fancy Excel functionality. What can you do?

It looks like Excel interprets the '#' as a 'magic #' whenever Excel creates hyperlinks. But if you create the hyperlink within Excel's object model, or modify the address of an existing hyperlink in Excel's object model, you can foist an un-magical # into Excel, or MS Word, or any other MS Office application that would normally have a problem.

I made some Excel code that does this automatically for a sheet containing column A full of pound-sign-containing addresses (the text only), which fills column B with new working hyperlinks. I was able to paste these hyperlinks successfully into Word and Outlook.

Sub Make_Column_A_into_hyperlinks_hashmarkworkaround()

    'Column "A" contains the text of links to some files.
    'This subroutine will turn those cells into Excel hyperlinks...
    '...and then correct the hyperlinks in case Excel misinterpreted
    'a # mark which had originally occurred in the filename.
    'Because I'm using selection.End(xlDown).Select to find the complete list,
    'this program does not tolerate any blanks in the "A" column list.
    'Note that I don't add a hyperlink in Row 1.

    Dim A As Object
    Dim lngRow As Long
    Dim Height As Long

    With ActiveSheet
        .Cells(1, 1).Select
        Selection.End(xlDown).Select
        Height = Selection.Row

        For lngRow = 2 To Height
            .Hyperlinks.Add Anchor:=ActiveSheet.Cells(lngRow, 2), Address:=Chr(34) & _
                ActiveSheet.Cells(lngRow, 1).Value & Chr(34), TextToDisplay:="Open", _
                ScreenTip:=Chr(34) & ActiveSheet.Cells(lngRow, 1).Value & Chr(34)
        Next

        For Each A In ActiveSheet.Hyperlinks

            If A.ScreenTip <> "" Then
                If InStr(1, A.ScreenTip, "#") <> 0 Then
                    A.Address = Mid(A.ScreenTip, 2, Len(A.ScreenTip) - 2)
                End If
            End If

        Next
    End With

End Sub
Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
elliot svensson
  • 593
  • 3
  • 11
0

This is really annoying but there's a simple workaround: don't use the URL with the # but use an URL-shortener service like https://goo.gl/

Christian
  • 13,285
  • 2
  • 32
  • 49
  • That's really the "solution" I used. Please comment before downvoting. – Christian Feb 14 '17 at 18:56
  • Dear Christian, the hash pound inside URLs is very used when developing Single-Page Apps, in which you use client-side javascript routers to change between sections of the application. For example it's very normal to have links like example.com/myapp#mysection1 – Sorin Postelnicu Feb 01 '18 at 13:48
  • So Excel is buggy if it removes the hash from a link, because the hash inside the link is part of normal W3 standards: https://www.w3.org/TR/html4/intro/intro.html#fragment-uri – Sorin Postelnicu Feb 01 '18 at 13:50
  • Even the last link I posted above itself contains an URI fragment :) – Sorin Postelnicu Feb 01 '18 at 13:51
  • Sure, I did not want to say that Excel has any right to remove the fragments. Just wanted to note a workaround while this bug is still there. – Christian Feb 01 '18 at 18:11
  • Unfortunately the workaround does not work for Single-Page Applications, where you use hashes :( – Sorin Postelnicu Feb 02 '18 at 20:30
  • Why not? For me it works very well. The "shortened" URL just forwards to the actual URL with hash in it. So the Single-page app just "sees" the URL with hash. – Christian Feb 04 '18 at 14:06
  • :) So the solution is that the Single-page app generates short URLs for each of the app sections or links? :) The whole idea was that the SPA uses the hash fragments to identify which section to route-to. – Sorin Postelnicu Feb 05 '18 at 15:27
  • Take the example of this "almost" SPA: http://ec.europa.eu/programmes/erasmus-plus/projects#search/keyword=europe&matchAllCountries=false – Sorin Postelnicu Feb 05 '18 at 15:29
  • All the links in the list of search results are dynamically generated, and they all contain the hash sign in the link. – Sorin Postelnicu Feb 05 '18 at 15:30
  • Sure, and that's fine. The user who wants to put such a link into Excel can shorten it manually and put the shortened link in Excel. No need to change the app or generate anything else with it. – Christian Feb 05 '18 at 16:24
  • You're right about that. That's the perfect solution when you have a few links to include in Excel file. (For us it happened that another app was generating an Excel including a few hundred links to pages inside our app, without using any URL shortener.) – Sorin Postelnicu Feb 06 '18 at 17:09
  • Ah, now I understand. Yep, for this case it would be possible but not be quite handy. – Christian Feb 07 '18 at 07:36
-2

Please try the below thread in order to get the URL to open from the IE window by its address using VBA

Using VBA to send url to an active IE window

Example below:

Dim IE As Object
Dim objCollection As Object

' Create InternetExplorer Object
Set IE = CreateObject("InternetExplorer.Application")

' Send the form data To URL As POST binary request
IE.Navigate "https://YOURURL/niku/nu#action:projmgr.projectDefaultTab&id=5558967"

' Clean up
Set IE = Nothing

Hope this works for you as it does for me. AmiK

Community
  • 1
  • 1
Ami Khan
  • 21
  • 1
  • 5
-2

The best solution we have found, without manually changing registry entries, is to reset Internet Explorer to be the default browser. This resets the url, protocol and extension associations and resolves the issue.

-3

Go to Control Panel -> All Control Panel Items -> Default Programs -> Set Default Programs and select Setup Internet Explorer as Default Browser.

Close all Internet Explorer tabs and try again.

Caleb Kleveter
  • 11,170
  • 8
  • 62
  • 92