URL property example

Sub HyperLinks_Example()
' This example adds an Mtext to the model space and
' adds a new Hyperlink to its Hyperlinks collection.
    Dim oMtext As AcadMText
    Dim sTextString As String
    Dim insPt(0 To 2) As Double: insPt(0) = 0: insPt(1) = 9
    sTextString = "\LSelect text, then right-click and use Hyperlink>Open"
    Set oMtext = ThisDrawing.ModelSpace.AddMText(insPt, 18, sTextString)
    oMtext.height = 1
    oMtext.width = 18
    oMtext.Update
    ThisDrawing.Application.ZoomExtents
    ' Get reference to the Mtext Hyperlinks collection
    Dim Hyperlinks As AcadHyperlinks
    Dim Hyperlink As AcadHyperlink
    Set Hyperlinks = oMtext.Hyperlinks
    ' Add a new Hyperlink complete with all properties
    Set Hyperlink = Hyperlinks.Add("Bricsys")
    Hyperlink.URL = "http://www.bricsys.com/en_INTL/bricscad/"
    Hyperlink.URLDescription = "The BricsCAD Site"
    Hyperlink.URLNamedLocation = "BricsCAD"
    ' create a list of existing Hyperlinks and their properties for this object
    Dim sBuf As String
    For Each Hyperlink In Hyperlinks
        sBuf = sBuf & "____________________________________" & vbCrLf
        sBuf = sBuf & "URL: " & Hyperlink.URL & vbCrLf
        sBuf = sBuf & "URL Description: " & Hyperlink.URLDescription & vbCrLf
        sBuf = sBuf & "URL Named Location: " & Hyperlink.URLNamedLocation & vbCrLf
    Next
    MsgBox "The Mtext object has " & Hyperlinks.count & " Hyperlink: " & vbCrLf & sBuf
End Sub

© Bricsys NV. All rights reserved.