Excel FollowHyperlink loads URL twice

I'm writing a web app which receives data from Excel 2010 on Windows 7 (64 bit). I'm using a small VBA macro for data upload and web page opening. However, when using ActiveWorkbook.FollowHyperlink in VBA the website is not opened by my default browser initially (Chrome in my example), but by some MS Office internal Internet Explorer instance. I'm redirecting from this first URL … and my real web browser is called on the redirected URL only. Got it? The header of the first access contains the following user agent:

User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; ms-office)

The server response with a redirect and the other url is called by the same user agent. At the end this second url is opened with my default browser, which happens to be:

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3

Unfortunately this is not useful, as I'm setting a cookie at the first request (where the redirect occurs). I only found an ugly solution using ShellExecute (so far):

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

and then opening the website by:

ShellExecute 0, vbNullString, "http://...", vbNullString, vbNullString, vbNormalFocus

Others seem to have the same problem (http://groups.google.com/group/microsoft.public.excel.programming/browse_thread/thread/3191ab7cbebe38e8). But ShellExecute really should only be a last resort. Never mind, it's just Microsoft.


1. anonymous -- 13 years ago

Danke für den Hinweis!

Diese idiotische Eigenschaft von Excel hat mich einige Nerven gekostet, vor allem weil man ja nicht direkt sieht, was da passiert. Ich musste erst den Sniffer anwerfen um dem auf die Schliche zu kommen.

Danke, Microsoft, für dieses tolle Feature!

2. anonymous -- 3 weeks ago

Mulan Lyrics by ANNA is a latest Italian song. ANNA has created its tune while brand new Mulan song lyrics are written by ANNA.

Source: https://www.lyricsbull.com/mulan-lyrics-anna/

3. anonymous -- 3 weeks ago

Piya Piya Piya Mera Jiya Pukare Lyrics from Baap Re Baap is Hindi song sung by Asha Bhosle, Kishore Kumar and music is given by O. P. Nayyar. Piya Piya Piya Mera Jiya Pukare song lyrics are written by Jan Nisar Akhtar.

Source: https://www.lyricsoff.com/songs/piya-piya-piya-mera-jiya-pukare.html

4. anonymous -- 3 weeks ago

Likha Hai Teri Aankhon Mein Lyrics from Teen Deviyan is Hindi song sung by Kishore Kumar, Lata Mangeshkar and music is given by Sachin Dev Burman. Likha Hai Teri Aankhon Mein song lyrics are written by Majrooh Sultanpuri.

Source: https://www.lyricsoff.com/songs/likha-hai-teri-aankhon-mein.html

5. anonymous -- 3 weeks ago

Duniya Kare Sawal Lyrics from Bahu Begum is Hindi song sung by Lata Mangeshkar and music is given by Roshan. Duniya Kare Sawal song lyrics are written by Sahir Ludhianvi.

Source: https://www.lyricsoff.com/songs/duniya-kare-sawal.html

Add New Comment