[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Using Default Browser

Posted on 1998-11-04
3
Medium Priority
?
152 Views
Last Modified: 2010-04-30
Can someone provide the code that would determine the users default browser and open it to a particular page?
0
Comment
Question by:clarwc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Accepted Solution

by:
idcanada earned 400 total points
ID: 1443048

' Place a Command Button and a Text Box

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
Private Const SW_SHOW = 5


Private Sub Command1_Click()
    text1.text = "http://www.total.net/~idc/"
    ShellExecute hwnd, "open", Text1.Text, vbNullString, vbNullString, SW_SHOW
End Sub

0
 
LVL 14

Expert Comment

by:waty
ID: 1443049
Bad luck, someone has responded just before me, by the way, here is my response :

Use the following function, to view an HTM file with its associated default browser :

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

Public Function ExecuteWithAssociate(ByVal hwnd As Long, sExecute As String, Optional Param As Variant, Optional windowstyle As Variant) As Boolean
   ' #VBIDEUtils#************************************************************
   ' * Programmer Name  : Waty Thierry
   ' * Web Site         : www.geocities.com/ResearchTriangle/6311/
   ' * E-Mail           : waty.thierry@usa.net
   ' * Date             : 9/10/98
   ' * Time             : 11:48
   ' * Module Name      : Execute_Module
   ' * Module Filename  :Execute.bas
   ' * Procedure Name   : ExecuteWithAssociate
   ' * Parameters       :
   ' *                    ByVal hWnd As Long
   ' *                    S As String
   ' *                    Optional Param As Variant
   ' *                    Optional windowstyle As Variant
   ' **********************************************************************
   ' * Comments         :
   ' * Executes a file with it's associated program.
   ' *   windowstyle uses the same constants as the Shell function:
   ' *      vbHide   0
   ' *      vbNormalFocus  1
   ' *      vbMinimizedFocus  2
   ' *      vbMaximizedFocus  3
   ' *      vbNormalNoFocus   4
   ' *      vbMinimizedNoFocus   6
   ' *
   ' *  returns true on success
   ' *
   ' *
   ' **********************************************************************
   
   Dim i As Long

   If IsMissing(windowstyle) Then windowstyle = vbNormalFocus

   i = ShellExecute(hwnd, vbNullString, sExecute, IIf(IsMissing(Param) Or (Param = ""), vbNullString, CStr(Param)), GetPath(sExecute), CLng(windowstyle))
   If i > 32 Then
      ExecuteWithAssociate = True
   Else
      ExecuteWithAssociate = False
   End If
   
End Function

Public Function GetPath(s As String) As String
   '
   '  Returns the path portion of a file + pathname
   '
   
   Dim i As Integer
   Dim J As Integer

   i = 0
   J = 0

   i = InStr(s, "\")
   Do While i <> 0
      J = i
      i = InStr(J + 1, s, "\")
   Loop

   If J = 0 Then
      GetPath = ""
   Else
      GetPath = Left$(s, J)
   End If

End Function

0
 

Author Comment

by:clarwc
ID: 1443050
Works Great thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question