create Hyperlink programmatically

How to create hyperlink and attach to an element in VBA?

Regards,

Jeffrey Kam

Parents
  • Engineering Links

    If by Hyperlink you mean an Engineering Link then it's done using tags. MicroStation uses a tag set named 'Internet' that contains tag definitions 'URL' and 'description' plus some others. MicroStation's Engineering Links tool will interpret tags created with that tag set and follow the hyperlink contained in the URL tag.

    With VBA, you create tags in the usual way using the 'Internet' tag set definition.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

Reply
  • Engineering Links

    If by Hyperlink you mean an Engineering Link then it's done using tags. MicroStation uses a tag set named 'Internet' that contains tag definitions 'URL' and 'description' plus some others. MicroStation's Engineering Links tool will interpret tags created with that tag set and follow the hyperlink contained in the URL tag.

    With VBA, you create tags in the usual way using the 'Internet' tag set definition.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

Children
  • Jeffrey,

    I use datablock to embed and retrieve the hyperlink. For example;

    Private Const attrId As Long = 22352

    Sub embed_hyperlink_as_datablock(elem  as ShapeElement)

         Dim dblk As New DataBlock,sqlWeb as string

         sqlWeb="www.google.com"

         dblk.CopyString sqlWeb, True

           elem.AddUserAttributeData attrId, dblk

           elem.Rewrite

    End Sub

    To get sqlWeb string use;

    Sub get_Hyperlink_from_Datablock(elem  as ShapeElement )

    dblk = elem.GetUserAttributeData(attrId)

    dblk(0).CopyString sqlWeb, False

    End Sub

    Regards,

    Olcay Ebcin

  • I did with the code followings

    TagSet tagset = app.ActiveDesignFile.TagSets.Add("Internet");

    TagDefinition tag = tagset.TagDefinitions.Add("URL", MsdTagType.msdTagTypeCharacter);

    tag.DefaultValue = "www.google.com";

    tag = tagset.TagDefinitions.Add("description", MsdTagType.msdTagTypeCharacter);

    elm.Current.AddTag(tag);

    elm.Rewrite();

    but it seems not work, what's wrong with my code?

    Regards,

    Jeffrey

  • You're confusing the Tag Set Definition with the TagElement you want to attach to a host element.

    See our Tag Data overview.

    Tag Set Definition

    The Internet tag set defines a tag set that has at least two Tag Definition children: URL and Description.

    You need to check whether the active DGN file already has the Internet tag set before you attempt to create it.

    Tag Attachment

    You can create & attach TagElements only if the Tag Set is already defined. You need a TagDefinition to be able to create a TagElement — the tag definition must already exist in the DGN file.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • Suppose Internet tagset with URL and Description TagDefinition defined in the design file, please take a look of my codes belows

    TagSet tagset = app.ActiveDesignFile.TagSets["Internet"];

    TagDefinition tag = tagset.TagDefinitions["URL"];

    TagElement tagElm = elm.AddTag(tag);

    tagElm.Value = "http://www.google.com";

    tagElm.Rewrite();

    tag = tagset.TagDefinitions["Description"];

    TagElement tagElm2 = oEE.Current.AddTag(tag);

    tagElm2.Value = "google";

    tagElm2.Rewrite();

    elm.Rewrite();

    The engineering link still not works. Can you see my problems?

    Regards,

    Jeffrey

  • this code works. sorry for misleading you. Thank you

    Regards,

    Jeffrey