VBA that can edit a link?

Hello Everyone,

                         I am working with a VBA that will add a link to an element, but I would like to have the option to edit the link once I have added it to an element.  For instance, I would like to be able to select an element, run my VBA, and then have the Edit Link window appear (see following picture).

Here is my VBA so far: 

Sub Macro1()
    Dim startPoint As Point3d
    Dim point As Point3d, point2 As Point3d
    Dim lngTemp As Long

'   Start a command
    CadInputQueue.SendKeyin "ELEMENT CREATE LINK URL http://www.google.com"

    CommandState.StartDefaultCommand
End Sub

  • Hi Jeff,

    as I wrote in my previous answer to another your question, there is no public Project Explorer VBA API, so any access to Project Explorer functionality (including links) is not straightforward or even not possible. Based on the situation I quite sure there is no way how to edit link from VBA.

    If one link only is attached to an element, you can use key-in links edit in such workflow:

    1. Add the element to selection set.
    2. Use key-in links edit.
    3. Confirm the action by data point.
    4. Standard edit link dialog will open.

    If you will record edit link tool using macro recorder, you will see the key-in links edit has some parameters, so it seems like it's possible to use the key-in without selecting the element in advance, but the parameters are not documented and they don't work if used from command line.

    With regards,

     Jan

  • Hi Jan,
    Thank you for your quick replys. What I wanted to do was to have the Edit Links window pop-up once I attached a link using my VBA. I managed to accomplish that with the following code:

    Sub Macro1()
    Dim startPoint As Point3d
    Dim point As Point3d, point2 As Point3d
    Dim lngTemp As Long

    ' Start a command
    CadInputQueue.SendKeyin "ELEMENT CREATE LINK URL http://www.google.com"

    ' Send a keyin that can be a command string
    CadInputQueue.SendKeyin "links edit"

    ' Send a data point to the current command
    point.X = startPoint.X
    point.Y = startPoint.Y
    point.Z = startPoint.Z
    CadInputQueue.SendDataPoint point, 1

    CommandState.StartDefaultCommand
    End Sub


    But now I would like to find a way to add a reference ID at the end of a URL based on point numbers I have in a drawing. Do you know of any MicroStation functions that would store the numbers of a point if they were highlighted? And would it be possible to reference that number into a VBA?
  • Hi Jeff,

    why do you create element link and in the next step you open link edit dialog?

    I am not sure why do you choose links, because they use from VBA is very limited - no direct access, you can create the link only by key-in, any other tasks have to be done using GUI... Maybe "good old" Engineering Links, which are based on tags, would be enough for you?

    Regards,

    Jan
  • Jan,
    I'm afraid you've misunderstood. I am not attempting to store my own information. What I am trying to do is create a VBA that will self-populate itself with highlighted numbers and text.

    Example:

    Let's say I have 3 different PDFs, and I have made 3 different URLs for these PDFs.
    And let's call these URLs www.pdfexamplesite.com/1, www.pdfexamplesite.com/2, www.pdfexamplesite.com/3.

    And let's say that the reason the reference IDs for each of these URLs are 1, 2, and 3 is because the
    PDFs they display correlate with point numbers 1, 2, and 3.


    So imagine a DGN that only has the level for point numbers turned on next to their respective point:

    *1 *2 *3

    And I would like to add a link to each of these elements which would display more information for each point.

    This would be simple enough if I had just three points, but let's pretend I have 1000 points. Now I need a VBA.

    So as of right now, I have a VBA (listed above) that will attach a link to an element and then will open the Edit
    Link window in order for me to differentiate the reference ID for each different URL I am attaching.

    Example:

    I will highlight point 1, run my VBA, and once the generic URL is attached (http://www.pdfExampleSite.com), I will then edit the URL to look something like this: www.pdfexamplesite.com/1

    Then I will highlight point 2, run my VBA, and once the generic URL is attached (http://www.pdfExampleSite.com), I will then edit the URL to look something like this: www.pdfexamplesite.com/2

    And so on.

    Now, what I would like to happen, is instead of manually entering each reference ID, is I would like to be able to click on a point's number, have that number populate my VBA (which would turn a URL from something like www.pdfexamplesite.com/X to www.pdfexamplesite.com/1, 2, 3, or whatever number I click), and then have that link added to the element (in this case it would be the point number, but that is ok for my purposes).

    Example:

    If I had a DGN with the three following points and point numbers:

    *1 *2 *3

    I highlight the point number 1, run my VBA, and have the following link attached to the point number 1: www.pdfexamplesite.com/1. And then when I repeat the above steps for point 2 I would get a link attached to point 2 that looks like this: www.pdfexamplesite.com/2.