followhyperlink happening twice

Skip to first unread message

Brian Murphy

Jun 22, 2010, 8:11:53 AM6/22/10
I am using the following statement to run an asp script on my web

ExcelApp.ActiveWorkbook.FollowHyperlink address:=""http://", NewWindow:=True

The above line is actually in a VB6 dll that I call from Excel VBA.
Anyway, the asp script displays a web page and sends me an email. The
page displays in the default browser just as expected, but I get two
emails when this line is called once from Excel.

If I enter the same URL string manually in the browser, I only get one
email. So something goofy is happening with the FollowHyperlink that
I don't understand.

Does anyone know why this would happen?


Brian Murphy
Austin, Texas


Jun 22, 2010, 8:55:14 AM6/22/10
Just a wild guess but maybe your code is in some event code and the
event gets triggered 2 times - like in ws_change event and 2 cells get
changed in sequence...

On Jun 22, 1:11 pm, Brian Murphy <> wrote:
> I am using the following statement to run an asp script on my web
> site.

> ExcelApp.ActiveWorkbook.FollowHyperlink address:=""", NewWindow:=True

Brian Murphy

Jun 22, 2010, 1:18:37 PM6/22/10
It's not called from any event procedures. I checked into the
possibility of the code getting executed twice by placing a breakpoint
on it. This confirmed that it's only getting called once.

I'm not 100% sure, but it's possible that every once in a while I only
get one email. But certainly most of the time I get two.



Peter T

Jun 23, 2010, 8:44:21 AM6/23/10
Putting a breakpoint in the routine can sometimes disguise it being called
twice, particularly from different types of "button" events. Maybe include a
debug line or write to a log file. However I don't think you've given us the
whole picture as your code simply opens a web page, no idea where those
emails are coming from.

I know Excel's FollowHyperlink is tempting for its simplicity even in a VB6
dll, but maybe try something like this -

Public 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
Public Declare Function GetDesktopWindow Lib "user32" () As Long

Sub test()
Dim sURL As String
sURL = ""

Call ShellExecute(GetDesktopWindow(), vbNullString, sURL, _
vbNullString, vbNullString, vbNormalFocus)
End Sub

Peter T

"Brian Murphy" <> wrote in message

Reply all
Reply to author
Message has been deleted
0 new messages