LaunchBrowserDialog 方法 (ActiveX)
启动一个对话框,用户可以在其中输入 URL。 支持的平台:仅限 Windows 签名VBA: RetVal = object.LaunchBrowserDialog(SelectedURL, DialogTitle, OpenButtonCaption, StartPageURL, RegistryRootKey, OpenButtonAlwaysEnabled)
返回值 (RetVal)类型:布尔
言论最后一个参数 OpenButtonAlwaysEnabled 确定用户是否可以选择 HTML 链接以及可下载的文件。 例子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", "https://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
可视化 LISP: Not available |
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-28 00:51
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.