Add links by VBA

Hi!

I am trying to create a script to add links to PDFs. For an example 2000 borehole elements that I want to add a link to.

I have recorded doing it manually and then cleaned up the code. My problem is it stops during the scipt...

Sub LinkToElement()

'Script scans elements

'For each element find a value in a excelfile PDF path etc

'Fix/sort the found values so that I can add it in the "CadInputQueue.SendKeyin Links Add Element ID ""Test.dgn"" 12345" below. Do not show that in the example below. Keep it simple :)

Part 1 

Dim modalHandler As New Macro1ModalHandler
    AddModalDialogEventsHandler modalHandler

     CadInputQueue.SendKeyin "Links Add Element ID ""Test.dgn"" 12345"

RemoveModalDialogEventsHandler modalHandler

CommandState.StartDefaultCommand

End Sub

The CadInputqueue tells what element that should have the link.

Part 2

Implements IModalDialogEvents
Private Sub IModalDialogEvents_OnDialogClosed(ByVal DialogBoxName As String, ByVal DialogResult As MsdDialogBoxResult)

End Sub

Private Sub IModalDialogEvents_OnDialogOpened(ByVal DialogBoxName As String, DialogResult As MsdDialogBoxResult)

    If DialogBoxName = "Create Links" Then

        DialogResult = msdDialogBoxResultCancel

    End If  ' Create Links

End Sub

My Macro1ModalHandler never continues when the "Create Links" toolbox open. Even if I only add DialogResult = msdDialogBoxResultCancel as a test in the Macro1ModalHandler it doesen't work. So it seems like the "Creat Links" box is in some kind of a modalmode and it stops the script from continuing.

Part 1 works if i choose the PDF manually. Then it adds the link on the element perfectly. It is my Macro1ModalHandler that I have trouble with...

Is there a work around?

Is there a keyin that directly add a link? Something like: Links Add Element ID ""Test.dgn"" 12345 C:\Users\*****\Desktop\PDF\T636.PDF

I only want to create link to a file. Not KeyIn or URL.

Thanks!

Parents Reply Children
No Data