Topic
12 replies Latest Post - ‏2013-11-27T14:08:48Z by dadere69
Abe H
Abe H
6 Posts
ACCEPTED ANSWER

Pinned topic Importing Word Tables as OLE Objects

‏2013-04-15T18:18:41Z |

Hi,

I have a Word document with many Word tables. The standard Import tool in Word brings these tables in as DOORS tables, of course. I'd really like to make these OLE objects instead of DOORS tables.

Is there a DXL file that can be edited to make this happen? I'm new to DXL but I'm hoping this wont be too difficult.

Thanks for the help.

Abe

 

I'm using DOORS  9.5 and Word 2010.

  • llandale
    llandale
    2809 Posts
    ACCEPTED ANSWER

    Re: Importing Word Tables as OLE Objects

    ‏2013-04-15T19:28:13Z  in response to Abe H

    The standard way is to manually:

    • Select the table in Word
    • Cut
    • Paste-Special .. Word Document Object

    Then import the file.

    Since the Word->To->DOORS "porting" is originated in Word, it doesn't make much sense to use DXL during the import.

    To do it with DXL you'd need OLE automation control.  Instead of using the rather clumsy DXL "OLE" interface I'd be very tempted to write a Word Macro that converted all tables found to OLE, then use DXL to command Word to run that macro.  Or just run the macro from Word.

    -Louie

    The main complaint about all the OLE tables in DOORS is that they are not searchable for key-words.  I'm tempted to resolve that complaint by taking each OLE in a DOORS module, paste into Word, then somehow strip out all the raw text and then insert all that text into a text attribute in DOORS perhaps named "OLE_Raw-Text".  Or convert everything in "Object Text" to raw text into attr "Object Text Raw" and encourage folks to search that attribute for their key words.  Tempted, not started.

    • Abe H
      Abe H
      6 Posts
      ACCEPTED ANSWER

      Re: Importing Word Tables as OLE Objects

      ‏2013-04-15T21:26:55Z  in response to llandale

      Louie,

      I think I read that the macro used for importing Word documents into DOORS is encrypted and therefore inaccessible.

      I'll certainly confirm this, but it sounds like DOORS will bring an OLE table in as an OLE object. If that's true, I like your idea of converting all tables in Word to OLE, that would solve my problem.

       

      Abe

    • Abe H
      Abe H
      6 Posts
      ACCEPTED ANSWER

      Re: Importing Word Tables as OLE Objects

      ‏2013-04-19T22:18:39Z  in response to llandale

      Today I was able to use vba to convert all Word tables to OLE, then exported to DOORS. For the most part, it worked great. I have noticed that the page orientation for all OLEs in DOORS is portrait, even though I made sure to convert them to landscape in Word.

      Is it possible to use DXL to change the page orientation inside of DOORS for OLEs?

      • WolfgangUhr
        WolfgangUhr
        64 Posts
        ACCEPTED ANSWER

        Re: Importing Word Tables as OLE Objects

        ‏2013-04-20T07:43:13Z  in response to Abe H

        Hi

        > Is it possible to use DXL to change the page orientation inside of DOORS for OLEs?

        I've googled for "word page orientatin vba" and I've found:

        http://stackoverflow.com/questions/13242369/word-document-set-to-landscape

        Then I've started word, opened the vba-editor and performed the code:

        Sub x() 
          Debug.Print 
          wdOrientLandscapeEnd 
        Sub
        

        The result was the integer value 1.

        Best regards

        Wolfgang

        Updated on 2013-04-20T07:43:43Z at 2013-04-20T07:43:43Z by WolfgangUhr
        • This reply was deleted by WolfgangUhr 2013-04-20T07:47:52Z. Reason for deletion: "Formated" problem seems to be solved
      • SharonS2
        SharonS2
        4 Posts
        ACCEPTED ANSWER

        Re: Importing Word Tables as OLE Objects

        ‏2013-07-19T14:20:19Z  in response to Abe H

        Hello Abe,

        I am spending HOURS converting Word tables to OLE objects!  Would it be possible for you to share your vba code that does this?

        Thank You,
        Sharon

        • abe777
          abe777
          8 Posts
          ACCEPTED ANSWER

          Re: Importing Word Tables as OLE Objects

          ‏2013-07-19T14:47:41Z  in response to SharonS2

          Sharon,

          Add this macro to the document you need to convert. I'd start with a copy of the original, unmodified file and see if it works for you.

          Abe

           

          Public Sub ConvertTablesToOLE()
          Dim rgeTable As Range
           
          With ActiveDocument
          Do While .Tables.Count > 0
          'Set range to first table and cut table
          Set rgeTable = .Tables(1).Range
          .Tables(1).Range.Select
           
          Selection.Cut
          Selection.TypeParagraph
          Selection.MoveUp Unit:=wdLine, Count:=1
           
           
          If Selection.PageSetup.Orientation = wdOrientPortrait Then
                  pageOrientation = wdOrientPortrait 'Selection.PageSetup.Orientation = wdOrientLandscape
          Else
                  pageOrientation = wdOrientLandscape 'Selection.PageSetup.Orientation = wdOrientPortrait
          End If
           
          'Create OLE
              Selection.InlineShapes.AddOLEObject ClassType:="Word.DocumentMacroEnabled.12", _
                  FileName:="", LinkToFile:=False, DisplayAsIcon:=False
              Selection.PasteAndFormat (wdFormatOriginalFormatting)
              Selection.Tables(1).Rows.Alignment = wdAlignRowCenter
           
              
              
              Selection.HomeKey Unit:=wdStory
           
              Selection.EndKey Unit:=wdLine, Extend:=wdExtend
              Selection.Delete Unit:=wdCharacter, Count:=1
              Selection.Delete Unit:=wdCharacter, Count:=1
              
              Selection.PageSetup.Orientation = pageOrientation
              
              
              Add_Macro_To_ThisWorkbook
              
              ActiveDocument.Save
              ActiveWindow.Close
           
          Loop
           
          End With
           
          End Sub
          • SharonS2
            SharonS2
            4 Posts
            ACCEPTED ANSWER

            Re: Importing Word Tables as OLE Objects

            ‏2013-07-19T15:22:20Z  in response to abe777

            Hi Abe,

            Thanks SOOOO much for your instant response.  I do have a question and that's regarding  "Add_Macro_To_ThisWorkbook" -  is this also your code?

            THANKS!
            Sharon

            • abe777
              abe777
              8 Posts
              ACCEPTED ANSWER

              Re: Importing Word Tables as OLE Objects

              ‏2013-07-19T15:31:27Z  in response to SharonS2

              Oh, sorry, you can delete the Add_Macro_To_ThisWorkbook line, that was a function that added a formatting macro to each OLE.

              Maybe I should explain why I needed to add macros to each OLE:

              DOORs imports each OLE in portrait orientation. So, if half of your OLEs are landscape, you'll have to go into each one in DOORs and correct it. Also, DOORs seems to clip the view of the table on the left and right sides...you see everything if you open the OLE from within DOORS, but otherwise some tables appear incomplete. I've found that reducing the table to 99% of the original size corrects this, but that has to be done for each table...and I had many, many tables. The solution was to append macros that corrected the orientation and size to each OLE, and then to use a bit of DXL to activate each OLE and run the embedded macros. So, if you also need this solution, I can share that too.

               

              Abe

               

              Abe

              Updated on 2013-07-19T15:49:43Z at 2013-07-19T15:49:43Z by abe777
              • SharonS2
                SharonS2
                4 Posts
                ACCEPTED ANSWER

                Re: Importing Word Tables as OLE Objects

                ‏2013-07-19T16:39:12Z  in response to abe777

                Hello again,  Your solution works beautifully on my simple document with just a few portrait tables.  Yay!!!!   But yes, the real thing has many landscape tables also, so I would most appreciate it if you could share your solution to that also.

                Thanks so much!

                • abe777
                  abe777
                  8 Posts
                  ACCEPTED ANSWER

                  Re: Importing Word Tables as OLE Objects

                  ‏2013-07-19T17:36:49Z  in response to SharonS2

                  Sharon,

                  Keep the "Add_Macro_To_ThisWorkbook" line in your OLE conversion macro, then add the code from the Add_Macro.txt file to your Visual Basic Macro Module as a new macro.

                  Once you've imported the Word file, run the DXL code in the DXL_Macro.rtf file. It will loop through each OLE, open it, and run the OrientMe macro.

                   

                  Let me know if you have any issues.

                  Abe

                  Attachments

                  • SharonS2
                    SharonS2
                    4 Posts
                    ACCEPTED ANSWER

                    Re: Importing Word Tables as OLE Objects

                    ‏2013-07-19T19:52:09Z  in response to abe777

                    Abe, Thank you so much once again! I ran the vba code you sent me earlier on my 200 page document and all the tables were converted to OLE objects!  Sooooo nice.  One thing, though, any text in the first cell of the tables was gone.  Any thoughts?  Not a big deal - easier to fix those cells in the few tables that had text than to be converting all the tables as I was. 

                    Unfortunately, I may not be able to look at your macro code until Monday as I have a bunch of other "fixes" to do in the Word doc first.

                    I can't tell you how much I appreciate all your help!  Have a great weekend!

                    Sharon

                    • dadere69
                      dadere69
                      5 Posts
                      ACCEPTED ANSWER

                      Re: Importing Word Tables as OLE Objects

                      ‏2013-11-27T14:08:48Z  in response to SharonS2

                      One thing, though, any text in the first cell of the tables was gone.  Any thoughts?  Not a big deal - easier to fix those cells in the few tables that had text than to be converting all the tables as I was. 

                      Hello,

                      Do anyone knows why the first cell of tables always disappear ?
                      However thanks fot this useful DXL code.

                      Abdel

                      Updated on 2013-11-27T14:09:26Z at 2013-11-27T14:09:26Z by dadere69