I have placed hyperlinks in an excel spreadsheet though my ruby-on-rails application. The links are to some privileged pages that require, After the login I am supposed to t
Not sure it's really an answer but I had the same problem with my application.
The whole application, including the home page, is protected (I'm using Devise). So whenever a user wants to access http://myapp, it redirects him to http://myapp/users/sign_in.
I think Devise uses a 301 or a 302 to redirect to the login screens.
My finding is that links clicked in Office and opening in IE cannot accomodate this redirect (no problem when Chrome is the default browser). Does it match your setup?
Ultimately, I have found no other solution but to link directly to the sign-in page... Maybe there are other options but I'm still looking for them.
EDIT: found this article (from 2006) about a bug in Outlook which totally matches our situation. Again, not a solution, but at least an explanation.
This issue normally happens in IE and i also faced the same problem.
Solution to this is very simple
<html>
<body>
Please wait, loading your page...
<script type="text/javascript">
function getQuerystring(key) {
key = key.replace(/[\[]/,"\\\[").replace(/ [\]]/,"\\\]");
var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
var query = regex.exec(window.location.href);
return query[1];
}
window.location = window.location.protocol + "//" + window.location.host + "/" + getQuerystring('page');
</script>
</body>
</html>
The links you are constructing in excel should be modified
For e.g Old link - http://test.com/post/comments/1 New link should be - http://test.com/redirect.html?page=post/comments/1
How this works.
When user clicks a link in excel it points to redirect.html and the javascript constructs the actual URL and redirects again to proper page, user will be navigated to actual page if already logged in else redirected to Login/Home page.
This is a problem with Excel's internal URL handling, which has issues with modern web design patterns (e.g. sessions + redirects).
Here's a client-side solution that bypasses Excel's internal mechanisms and uses the OS default URL handler instead. Note that since it uses macros, this approach requires appropriate security settings.
In your worksheet's VBA module, add the following code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hWnd As Long, _
ByVal Operation As String, _
ByVal Filename As String, _
Optional ByVal Parameters As String, _
Optional ByVal Directory As String, _
Optional ByVal WindowStyle As Long = vbMinimizedFocus _
) As Long
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
ShellExecute 0, "Open", Target.Address
End Sub
This is based on the answers of two other SO answers.