LaunchBrowserDialog Method (ActiveX)

Launches a dialog box in which a user can enter a URL.

Supported platforms: Windows only

Signature

VBA:

RetVal = object.LaunchBrowserDialog(SelectedURL, DialogTitle, OpenButtonCaption, StartPageURL, RegistryRootKey, OpenButtonAlwaysEnabled)
object

Type: Utility

The object this method applies to.

SelectedURL

Access: Output-only

Type: String

The URL selected.

DialogTitle

Access: Input-only

Type: String

The title to be displayed in the dialog box.

OpenButtonCaption

Access: Input-only

Type: String

The caption for the OK/Open button.

StartPageURL

Access: Input-only

Type: String

An initial URL to be displayed.

ReigstryRootKey

Access: Input-only

Type: String

Product root key for storing persistent dialog box information. This key specifies where information about the size, position, and other preferences information of the dialog box can be stored across sessions. Input an empty string to disregard this functionality.

OpenButtonAlwaysEnabled

Access: Input-only

Type: Boolean

  • True: The Open button is enabled, allowing a file or link to be selected.
  • False: The Open button is disabled and is only enabled when the user selects a file for download.

Return Value (RetVal)

Type: Boolean

Remarks

The last parameter, OpenButtonAlwaysEnabled, determines whether the user can select HTML links in addition to files that can be downloaded.

Examples

VBA:

Sub Example_LaunchBrowserDialog()
    ' This example will prompt the user for a URL to download and will verify that
    ' a proper URL was entered.  After downloading, the example will attempt to load
    ' the downloaded URL as a drawing.
    '
    ' * Note: Remember to delete the downloaded file from your disk drive when finished.
    
    Dim Utility As AcadUtility
    Dim URL As String, DestFile As String, FileURL As String
    
    Set Utility = ThisDrawing.Utility   ' Connect to Utility object
    
GETURL:
    ' Prompt user for a URL to download.  This should be a URL to an AutoCAD drawing file.
    URL = InputBox("Enter the complete URL of the file you wish to download. " & _
                    "Enter BROWSER to select the URL from a web browser", _
                    "Enter URL To Download", URL)
    
    URL = Trim(URL)                     ' Get rid of blank spaces
    
    If URL = "" Then Exit Sub           ' Did user cancel

    ' Does the user want to select from a browser?
    If StrComp(URL, "BROWSER", vbTextCompare) = 0 Then
        Utility.LaunchBrowserDialog _
        URL, "AutoCAD Browser", "Open", "http://www.autodesk.com", "ACADBROWSER", True
        
        GoTo GETURL     ' Return to display chosen URL and allow modifications
    End If

    ' Determine if user entered a valid URL; if not, prompt again
    If Not (Utility.IsURL(URL)) Then
        MsgBox "The URL you entered is not valid.  Make sure the syntax is a valid URL."
        GoTo GETURL
    End If
        
    ' Download URL
    Utility.GetRemoteFile URL, DestFile, True
    
    ' Display downloaded file information
    MsgBox URL & " was downloaded to: " & DestFile & vbCrLf & vbCrLf & _
           "Press any key to attempt to load the new file as a drawing."

    ' Attempt to load file as drawing; if an error occurs, this was probably not a drawing
    ' file, but rather the text from a web page.
    ' Try loading the downloaded file into a text editor to view the contents.
    On Error Resume Next
    ThisDrawing.Application.Documents.Open DestFile
    If Err.Number <> 0 Then
        MsgBox "Error loading downloaded file as a drawing: " & Err.Description & vbCrLf & vbCrLf & _
               "This is probably not a valid drawing file!"
    End If
    On Error GoTo 0
    
    ' Use IsRemoteFile to determine if this file was downloaded from a URL.
    ' If it was, display the URL it was downloaded from
    '
    ' * Note: Although the results IsRemoteFile will return are already known because
    ' the file was just downloaded, it is important to know how this
    ' method can be used.
    If Utility.IsRemoteFile(DestFile, FileURL) Then
        MsgBox "The file: " & DestFile & " is a downloaded file and was downloaded from: " & FileURL
    Else
        MsgBox "The file: " & DestFile & " is not a downloaded file."
    End If

End Sub

Visual LISP:

Not available