Hyperlinks in Excel

I’m creating links in excel to PDF documents on a web server at work, but the links are not working as expected.

If you click on the link in Excel it opens a new tab in IE, however, it redirects you to some login page for the web server instead of opening up the PDF.

Now, if you copy that same link from Excel and paste it directly into IE, the PDF document is loaded.

If you go back to Excel and click on the link again the PDF document is loaded in IE. I’m guessing this is because IE has cached the link or whatever, so now it “trusts” it.

I have tried creating the link in VBA and also using the hyperlink function, and I get the same result. The creation of the link doesn’t appear to be the issue. I wan’t to say IE is the culprit here, but since you can copy and paste the link directly into IE with no issues, it sort of makes me think Excel is doing something funky by putting some kind of restriction on the link.

So to come full circle. When clicking on the link for the first time in Excel the PDF document is not loaded in IE, instead you’re redirected to a different page. Once you are able to load the document, via directly copying and pasting the link in IE, any subsequent clicks on that same link in Excel loads the PDF document in IE.

Completely stumped.

Just going off of this:


You could work around the issue, by making the file a read-only file. If the file needs to be edited, the user could download it and edit it. ( I assume this works, only because I believe that is what MS is saying. I have no experience with this. )

Interesting. Unfortunately, since this is for work I don’t have access to edit the registry. I tried using the code below, but that didn’t work either. However, I’m not sure if I’m using the HeaderInfo correctly.

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) 
ThisWorkbook.FollowHyperlink Address:=url, _
  ExtraInfo:="", _
  Method:=msoMethodGet, _
  HeaderInfo:="Content-type: application/pdf; readonly=true"
End Sub

More info on this can be found here