Use of Web Browser control in desktop app opens links in Outlook XP and not IE

  • Thread starter Thread starter Jan K.
  • Start date Start date
J

Jan K.

Hi,

I've posted this mail to the outlook.configuration but haven't been
able to get an answer to my issue as yet, so was hoping that someone
in this group could point me in the right direction.

I have an "Alerts" client desktop application written in VB6 that
makes use of the web browser control (Shdocvw.dll). The application
displays a rolling list of alert titles, and when the user clicks on
one of the titles, an Internet Explorer instance should open with the
url address value stored with the alert properties.

This has been working fine for a long time now, but when clients are
using XP with Outlook (Office 2000), the link opens in Outlook rather
than IE (This only happens if Outlook has been started, and only on
certain XP machines).

Is there any setting on XP, Internet Explorer or Outlook that affects
this behaviour, and how can I configure them to open these links in IE
rather than Outlook?

Have tried with the Tools- Internet Options- Programs- checking
"Internet Explorer should check if it is the default browser.." but
with no results.

Regards,
Jan
 
Show the code you use. I don't see that here when I use the Internet control
in Outlook 2000, 2002 or 2003.
 
Hi Ken,

Please find the code that is used.

The code does a check whether an instance of an IE is loaded or not,
otherwise creates the InternetExplorer.Application object and uses
that.

The issue is that the link will open in Outlook only on certain XP
configurations (and only when Outlook and/or IE is opened at the same
time), and not on others.

Hope this helps.

Rgrds,Jan

Set ShellEnv = New SHDocVw.ShellWindows
Set IE = ShellEnv.InternetExplorer

bFound = False
If Not ShellEnv Is Nothing Then 'IE is loaded

For Each IE In ShellEnv
Set IEDoc = IE.Document
IEHwnd = IE.hwnd
If bFound Then
rtnVal = ShowWindow(IEHwnd, SW_SHOWMINIMIZED)
Else
If TypeOf IEDoc Is HTMLDocument Then
ieAddr = IEDoc.location
bFound = True
frmAlerts.List1.AddItem "IE Address = " & ieAddr
IE.Navigate strWeb & strRedirectAddr & "?addr=" &
CheckforAmpersand(strAddr)
rtnVal = ShowWindow(IEHwnd, SW_SHOWMAXIMIZED)
rtnVal = SetFocus(IEHwnd)
rtnVal = BringWindowToTop(IEHwnd)
Else
rtnVal = ShowWindow(IEHwnd, SW_SHOWMINIMIZED)
End If
End If
Next
If Not bFound Then ' html doc NOT FOUND
Set IE = CreateObject("InternetExplorer.application")
If IE Is Nothing Then
MsgBox ("Unable to Create Internet Explorer
Application")
Else
IEHwnd = IE.hwnd
rtnVal = ShowWindow(IEHwnd, SW_SHOWMAXIMIZED)
IE.Navigate strWeb & strRedirectAddr & "?addr=" &
CheckforAmpersand(strAddr)
End If
End If
Else ' IE Not Loaded
Set IE = CreateObject("InternetExplorer.application")
If Not IE Is Nothing Then
IEHwnd = IE.hwnd
rtnVal = ShowWindow(IEHwnd, SW_SHOWMAXIMIZED)
IE.Navigate strWeb & strRedirectAddr & "?addr=" &
CheckforAmpersand(strAddr)
Else
errMsg = "Unable to find Internet Explorer," & vbCrLf
errMsg = errMsg & "Please contact the support desk for
further assitance."
Call MsgBox(errMsg, vbCritical + vbOKOnly, "Critical")
End If
End If
frmAlerts.Text8.Text = strWeb & strRedirectAddr & "?addr=" &
CheckforAmpersand(strAddr)
End Sub
 
Wow. That's a lot more code than I use. Here's what I do in one of my
commercial addins to open IE and navigate to a Web site page when a Purchase
button is clicked:

Private Sub cmdPurchase_Click()
Dim objIEApp As SHDocVw.InternetExplorer

On Error Resume Next

Set objIEApp = CreateObject("InternetExplorer.Application")

objIEApp.Navigate
"http://www.slovaktech.com/remindermanager/RMPricing.htm#Register"
objIEApp.Visible = True

Set objIEApp = Nothing
End Sub




Jan K. said:
Hi Ken,

Please find the code that is used.

The code does a check whether an instance of an IE is loaded or not,
otherwise creates the InternetExplorer.Application object and uses
that.

The issue is that the link will open in Outlook only on certain XP
configurations (and only when Outlook and/or IE is opened at the same
time), and not on others.

Hope this helps.

Rgrds,Jan

Set ShellEnv = New SHDocVw.ShellWindows
Set IE = ShellEnv.InternetExplorer

bFound = False
If Not ShellEnv Is Nothing Then 'IE is loaded

For Each IE In ShellEnv
Set IEDoc = IE.Document
IEHwnd = IE.hwnd
If bFound Then
rtnVal = ShowWindow(IEHwnd, SW_SHOWMINIMIZED)
Else
If TypeOf IEDoc Is HTMLDocument Then
ieAddr = IEDoc.location
bFound = True
frmAlerts.List1.AddItem "IE Address = " & ieAddr
IE.Navigate strWeb & strRedirectAddr & "?addr=" &
CheckforAmpersand(strAddr)
rtnVal = ShowWindow(IEHwnd, SW_SHOWMAXIMIZED)
rtnVal = SetFocus(IEHwnd)
rtnVal = BringWindowToTop(IEHwnd)
Else
rtnVal = ShowWindow(IEHwnd, SW_SHOWMINIMIZED)
End If
End If
Next
If Not bFound Then ' html doc NOT FOUND
Set IE = CreateObject("InternetExplorer.application")
If IE Is Nothing Then
MsgBox ("Unable to Create Internet Explorer
Application")
Else
IEHwnd = IE.hwnd
rtnVal = ShowWindow(IEHwnd, SW_SHOWMAXIMIZED)
IE.Navigate strWeb & strRedirectAddr & "?addr=" &
CheckforAmpersand(strAddr)
End If
End If
Else ' IE Not Loaded
Set IE = CreateObject("InternetExplorer.application")
If Not IE Is Nothing Then
IEHwnd = IE.hwnd
rtnVal = ShowWindow(IEHwnd, SW_SHOWMAXIMIZED)
IE.Navigate strWeb & strRedirectAddr & "?addr=" &
CheckforAmpersand(strAddr)
Else
errMsg = "Unable to find Internet Explorer," & vbCrLf
errMsg = errMsg & "Please contact the support desk for
further assitance."
Call MsgBox(errMsg, vbCritical + vbOKOnly, "Critical")
End If
End If
frmAlerts.Text8.Text = strWeb & strRedirectAddr & "?addr=" &
CheckforAmpersand(strAddr)
End Sub


"Ken Slovak - [MVP - Outlook]" <[email protected]> wrote in message
Show the code you use. I don't see that here when I use the Internet control
in Outlook 2000, 2002 or 2003.
 
Hi Ken,

Please find the code below.

It does a check if there's an instance of an htmldoc and loads it
there, otherwise it creates the InternetExplorer.Application object
and uses that.

However, only on certain XP configurations does this link open in
Outlook (when Outlook and/or the browser is opened) - on other XP
machines it will still open in the browser as desired.

Regards,
Jan


Set ShellEnv = New SHDocVw.ShellWindows
Set IE = ShellEnv.InternetExplorer

bFound = False
If Not ShellEnv Is Nothing Then 'IE is loaded

For Each IE In ShellEnv
Set IEDoc = IE.Document
IEHwnd = IE.hwnd
If bFound Then
rtnVal = ShowWindow(IEHwnd, SW_SHOWMINIMIZED)
Else
If TypeOf IEDoc Is HTMLDocument Then
ieAddr = IEDoc.location
bFound = True
frmAlerts.List1.AddItem "IE Address = " & ieAddr
IE.Navigate strWeb & strRedirectAddr & "?addr=" &
CheckforAmpersand(strAddr)
rtnVal = ShowWindow(IEHwnd, SW_SHOWMAXIMIZED)
rtnVal = SetFocus(IEHwnd)
rtnVal = BringWindowToTop(IEHwnd)
Else
rtnVal = ShowWindow(IEHwnd, SW_SHOWMINIMIZED)
End If
End If
Next
If Not bFound Then ' html dOC NOT FOUND
Set IE = CreateObject("InternetExplorer.application")
If IE Is Nothing Then
MsgBox ("Unable to Create Internet Explorer
Application")
Else
IEHwnd = IE.hwnd
rtnVal = ShowWindow(IEHwnd, SW_SHOWMAXIMIZED)
IE.Navigate strWeb & strRedirectAddr & "?addr=" &
CheckforAmpersand(strAddr)
End If
End If
Else ' IE Not Loaded
Set IE = CreateObject("InternetExplorer.application")
If Not IE Is Nothing Then
IEHwnd = IE.hwnd
rtnVal = ShowWindow(IEHwnd, SW_SHOWMAXIMIZED)
IE.Navigate strWeb & strRedirectAddr & "?addr=" &
CheckforAmpersand(strAddr)
Else
errMsg = "Unable to find Internet Explorer," & vbCrLf
errMsg = errMsg & "Please contact the support desk for
further assitance."
Call MsgBox(errMsg, vbCritical + vbOKOnly, "Critical")
End If
End If
frmAlerts.Text8.Text = strWeb & strRedirectAddr & "?addr=" &
CheckforAmpersand(strAddr)
End Sub
 
Thanks Ken for the reply,

Yes, it's more code than what is needed, but the problem is that this
inherited application is deployed to several thousands client
machines, and even though tempting I rather stay away from changing
this code and avoiding the logistics and the risks involved with
pushing the client component out.

Would you happen to know why it's opening the url in the Outlook on
some XP machines but not on others??? If I can find out a
configuration setting or a desktop policy settings which controls this
behaviour - then it's a matter of changing this on the client machine
rather than to have to rewrite the client app at this stage.

Rgrds,
Jan



Ken Slovak - said:
Wow. That's a lot more code than I use. Here's what I do in one of my
commercial addins to open IE and navigate to a Web site page when a Purchase
button is clicked:

Private Sub cmdPurchase_Click()
Dim objIEApp As SHDocVw.InternetExplorer

On Error Resume Next

Set objIEApp = CreateObject("InternetExplorer.Application")

objIEApp.Navigate
"http://www.slovaktech.com/remindermanager/RMPricing.htm#Register"
objIEApp.Visible = True

Set objIEApp = Nothing
End Sub




Jan K. said:
Hi Ken,

Please find the code that is used.

The code does a check whether an instance of an IE is loaded or not,
otherwise creates the InternetExplorer.Application object and uses
that.

The issue is that the link will open in Outlook only on certain XP
configurations (and only when Outlook and/or IE is opened at the same
time), and not on others.

Hope this helps.

Rgrds,Jan

Set ShellEnv = New SHDocVw.ShellWindows
Set IE = ShellEnv.InternetExplorer

bFound = False
If Not ShellEnv Is Nothing Then 'IE is loaded

For Each IE In ShellEnv
Set IEDoc = IE.Document
IEHwnd = IE.hwnd
If bFound Then
rtnVal = ShowWindow(IEHwnd, SW_SHOWMINIMIZED)
Else
If TypeOf IEDoc Is HTMLDocument Then
ieAddr = IEDoc.location
bFound = True
frmAlerts.List1.AddItem "IE Address = " & ieAddr
IE.Navigate strWeb & strRedirectAddr & "?addr=" &
CheckforAmpersand(strAddr)
rtnVal = ShowWindow(IEHwnd, SW_SHOWMAXIMIZED)
rtnVal = SetFocus(IEHwnd)
rtnVal = BringWindowToTop(IEHwnd)
Else
rtnVal = ShowWindow(IEHwnd, SW_SHOWMINIMIZED)
End If
End If
Next
If Not bFound Then ' html doc NOT FOUND
Set IE = CreateObject("InternetExplorer.application")
If IE Is Nothing Then
MsgBox ("Unable to Create Internet Explorer
Application")
Else
IEHwnd = IE.hwnd
rtnVal = ShowWindow(IEHwnd, SW_SHOWMAXIMIZED)
IE.Navigate strWeb & strRedirectAddr & "?addr=" &
CheckforAmpersand(strAddr)
End If
End If
Else ' IE Not Loaded
Set IE = CreateObject("InternetExplorer.application")
If Not IE Is Nothing Then
IEHwnd = IE.hwnd
rtnVal = ShowWindow(IEHwnd, SW_SHOWMAXIMIZED)
IE.Navigate strWeb & strRedirectAddr & "?addr=" &
CheckforAmpersand(strAddr)
Else
errMsg = "Unable to find Internet Explorer," & vbCrLf
errMsg = errMsg & "Please contact the support desk for
further assitance."
Call MsgBox(errMsg, vbCritical + vbOKOnly, "Critical")
End If
End If
frmAlerts.Text8.Text = strWeb & strRedirectAddr & "?addr=" &
CheckforAmpersand(strAddr)
End Sub


"Ken Slovak - [MVP - Outlook]" <[email protected]> wrote in message
Show the code you use. I don't see that here when I use the Internet control
in Outlook 2000, 2002 or 2003.




Hi,

I've posted this mail to the outlook.configuration but haven't been
able to get an answer to my issue as yet, so was hoping that someone
in this group could point me in the right direction.

I have an "Alerts" client desktop application written in VB6 that
makes use of the web browser control (Shdocvw.dll). The application
displays a rolling list of alert titles, and when the user clicks on
one of the titles, an Internet Explorer instance should open with the
url address value stored with the alert properties.

This has been working fine for a long time now, but when clients are
using XP with Outlook (Office 2000), the link opens in Outlook rather
than IE (This only happens if Outlook has been started, and only on
certain XP machines).

Is there any setting on XP, Internet Explorer or Outlook that affects
this behaviour, and how can I configure them to open these links in IE
rather than Outlook?

Have tried with the Tools- Internet Options- Programs- checking
"Internet Explorer should check if it is the default browser.." but
with no results.

Regards,
Jan
 
I have no idea why it works on some configurations and not on others. You
will have to compile a list of where it doesn't work and see what those
setups have in common and what the ones where it does work as desired have
in common.

If you can make up a quickie addin or exe that just has the code I showed
you and see if that also does the same thing on those problem systems it
might help you discover where the problem is coming from. FWIW I've never
the problem here on any of my Outlook setups.
 
In the end I ended up changing the code instead, applying your shorter
style of code, thanks. and this works. In addition, I added a
condition where parts of the string value in IEDoc.location has to
meet a certain criteria (just to make sure it doesn't open in Outlook
or any other instances which might be processed as equivalent to an
IEDoc object).

Thanks,
Jan
 
Back
Top