Consulting

Results 1 to 4 of 4

Thread: Set to default browser

  1. #1

    Set to default browser

    Can someone help change this to call the default browser, not Internet browser. Thanks for your help.

    [VBA]Function VersionCheck() As String
    Dim strControlID As String
    Dim strReportID As String
    Dim oBrowser As Object 'InternetExplorer
    Dim sURL As String
    Dim strVersion As String

    sURL = "http://www.pdtraveler.com/download.htm"
    Set oBrowser = Nothing: Set oBrowser = CreateObject("InternetExplorer.Application")
    oBrowser.Silent = True
    oBrowser.Navigate sURL
    Do
    Loop Until oBrowser.ReadyState = 4
    strVersion = oBrowser.document.DocumentElement.innerText
    If strVersion = vbNullString Then Exit Function
    strVersion = Mid(strVersion, InStr(1, strVersion, "Version"), 25)
    strVersion = Trim(Left(strVersion, InStr(1, strVersion, vbCrLf) - 1))
    VersionCheck = strVersion
    oBrowser.Quit
    End Function[/VBA]

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]Sub default()
    Dim objshell As Object
    Set objshell = CreateObject("Shell.Application")
    objshell.Open "http://www.pdtraveler.com/download.htm"
    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Mentor Justinlabenne's Avatar
    Joined
    Jul 2004
    Location
    Clyde, Ohio
    Posts
    408
    Location
    Or if you prefer api..

    [VBA]
    Option Explicit
    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 Sub FireUpABrowser(ByVal url As String)
    ShellExecute 0&, "open", url, 0&, 0&, 1
    End Sub

    Public Sub TestMethodAbove()
    FireUpABrowser "http://www.google.com"
    End Sub
    [/VBA]
    Justin Labenne

  4. #4
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Just opening a URL by another browser may not meet your needs. If you are going to use the MSIE objects, methods and properties, you need that object.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •