Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
3 replies Latest Post - ‏2013-04-23T19:02:18Z by Abe H
Abe H
Abe H
6 Posts
ACCEPTED ANSWER

Pinned topic Using DXL to Run a VBA Macro on OLE object

‏2013-04-22T20:19:16Z |

I have imported a Word document with many tables into DOORS. Prior to the import, I converted all tables to OLE objects (Macro Enabled Word Files) and added a macro to each. I now need to loop through each of the OLE objects in DOORS and run the macro. I've seen a few discussions about DXL and VBA, but I'm having trouble getting started.

Things I don't know, but believe I need:

1. I need to identify if a DOORS object is a Word OLE (the module has a few image OLEs, and trying to run a non-existent macro in those would surely generate an error)

2. I may need to activate the Word OLE, and then run its only macro. Or I might be able to run the macro without activating/opening the OLE.

I'm doing this because DOORS appears to import all Word OLEs with Portrait page orientation. Thus, OLEs in my Word document with Landscape orientation end up in DOORS with Portrait orientation, which makes the table display incomplete.

Any help would be appreciated. (Using Word 12 and DOORS 9.5)

 

Abe

  • GregM_dxler
    GregM_dxler
    163 Posts
    ACCEPTED ANSWER

    Re: Using DXL to Run a VBA Macro on OLE object

    ‏2013-04-22T22:09:37Z  in response to Abe H

    Hi Abe,

    Identifying and launching word can be done.  Not sure how to launch a macro but should be able to be done.

    Greg

    Attachments

  • llandale
    llandale
    2943 Posts
    ACCEPTED ANSWER

    Re: Using DXL to Run a VBA Macro on OLE object

    ‏2013-04-23T13:30:51Z  in response to Abe H

    Running a named Macro in your Word file looks like this:

    • OleAutoObj oaoWord   = get Application Handle
    • OleAutoArgs oaaArgs = create
    • clear oaaArgs
    • put  (oaaArgs, in_NameMacro)
    • oleMethod(oaoWord, "Run", oaaArgs)

    I did not know that an "embedded word document" (OLE Diagram) was it's own "file" and could have it's own "macros".  In any case it sounds like all your OLE diagrams use the same Macro, in which case you wouldn't need to store that macro with each OLE.  I'm guessing the "in_NameMacro" above could indeed be the entire text of the macro instead of just a name of a macro in Word.

    I may be wrong, but when you original create the OLE from the table you could do the following:

    1. Select and cut the table
    2. Paste-Special "Word Document Object"
    3. With the Word Document Object window open, adjust Page Layout to Landscape
    4. Adjust margins to fit the diagram
    5. Close the document object window
    6. Back in the main windows, adjust Page Layout to Landscape.

    -Louie

    • Abe H
      Abe H
      6 Posts
      ACCEPTED ANSWER

      Re: Using DXL to Run a VBA Macro on OLE object

      ‏2013-04-23T19:02:18Z  in response to llandale

      Louie,

      I have DXL running the macro embedded in the OLE. And you're right about replacing in_NameMacro with the macro text, it works. I'm using ".isOle" to check if the object is OLE (which I believe I found in one of your other posts). This is great, thanks for the help.

      DOORS still imports the OLE in Portrait page orientation no matter what I have set in the Word Document. I'm pretty sure the import code is resetting this.

       

      Abe