get info from doors from VBA application

Hi i have to import some info from Doors in a Word file using a VBA application.

I tried two way and i get to wrong behaviours.

First solution (runFile):

VBA code:

    Public Sub Main()

        Set DOORSObj = CreateObject("DOORS.Application")
        
        DOORSObj.runFile ("C...\provaDoors.dxl")
        Dim s As String
        s = ""
        s = DOORSObj.Result
        Selection.TypeText Text:=s
    End Sub

 

DXL Code:

pragma encoding, "UTF-8"

Object o=current
string s=richTextWithOle o."Object Text"

oleSetResult(s)

In this way i get "OK" as result  ("OK" is not the object text), if i try other attributes sometime it works but i always get this error in doors:

-R-E- DXL: <C:\Users\Admin\Documents\Altran\DXL Development\Common Scripts\Useful code\provaDoors.dxl:10> null Object parameter was passed into argument position 1
-I- DXL: execution halted

Other strange behavour i get that it is that i try to print attributeX and it works. I change the dxl script and i try to prin attribute Y (i save) and it print me still the attribute X until i restart Doors again!

Second solution (runstr):

VBA code:

    Set DOORSObj = CreateObject("DOORS.Application")
    Dim script As String
    script = "Object o = current; string s=richTextWithOle o.""Object Text""; oleSetResult (s)"
        
    DOORSObj.runStr (script)
    Dim s As String
    s = ""
    s = DOORSObj.Result
    Selection.TypeText Text:=s

 

This solution block doors and do nothing.

Thanks for the help


bungle_77 - Tue May 13 06:13:16 EDT 2014

Re: get info from doors from VBA application
llandale - Tue May 13 09:13:57 EDT 2014

I'm not good at OLE automation.  But..

  • If DOORS is already open I think you need [GetObject("DOORS.Application")].  Seems to me that CreateObject will start a new instance, requiring you to log in.
  • I think your DXL code needs to check for null o (current Object).
  • I think your VBA needs to close (?or delete?) DOORSObj.  I'm wondering if failing to do so leaves the pipe open, causing failure the next time you run the VBA.
  • I think if you open a module that has a "current Object", then click on the Explorer, then run the VBA, that the context is the explorer and that there is in fact no current Object (nor module) for the script.  DXL context for "current" is a little sticky.

-Louie

Re: get info from doors from VBA application
bungle_77 - Tue May 13 09:31:44 EDT 2014

llandale - Tue May 13 09:13:57 EDT 2014

I'm not good at OLE automation.  But..

  • If DOORS is already open I think you need [GetObject("DOORS.Application")].  Seems to me that CreateObject will start a new instance, requiring you to log in.
  • I think your DXL code needs to check for null o (current Object).
  • I think your VBA needs to close (?or delete?) DOORSObj.  I'm wondering if failing to do so leaves the pipe open, causing failure the next time you run the VBA.
  • I think if you open a module that has a "current Object", then click on the Explorer, then run the VBA, that the context is the explorer and that there is in fact no current Object (nor module) for the script.  DXL context for "current" is a little sticky.

-Louie

thanks... my code is just silly code to make a try. The steps 2 and 3 you highlighted makes sense and i was already conscious about them. I think step 1 and 4 can be more important for me. I will make some test and let you know