Importing Word Tables as OLE Objects

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.


Abe H - Mon Apr 15 14:18:41 EDT 2013

Re: Importing Word Tables as OLE Objects
llandale - Mon Apr 15 15:28:13 EDT 2013

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.

Re: Importing Word Tables as OLE Objects
Abe H - Mon Apr 15 17:26:55 EDT 2013

llandale - Mon Apr 15 15:28:13 EDT 2013

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.

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

Re: Importing Word Tables as OLE Objects
Abe H - Fri Apr 19 18:18:39 EDT 2013

llandale - Mon Apr 15 15:28:13 EDT 2013

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.

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?

Re: Importing Word Tables as OLE Objects
Wolfgang Uhr - Sat Apr 20 03:43:13 EDT 2013

Abe H - Fri Apr 19 18:18:39 EDT 2013

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?

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

Re: Importing Word Tables as OLE Objects
SharonS2 - Fri Jul 19 10:20:19 EDT 2013

Abe H - Fri Apr 19 18:18:39 EDT 2013

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?

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

Re: Importing Word Tables as OLE Objects
abe777 - Fri Jul 19 10:47:41 EDT 2013

SharonS2 - Fri Jul 19 10:20:19 EDT 2013

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

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

Re: Importing Word Tables as OLE Objects
SharonS2 - Fri Jul 19 11:22:20 EDT 2013

abe777 - Fri Jul 19 10:47:41 EDT 2013

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

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

Re: Importing Word Tables as OLE Objects
abe777 - Fri Jul 19 11:31:27 EDT 2013

SharonS2 - Fri Jul 19 11:22:20 EDT 2013

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

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

Re: Importing Word Tables as OLE Objects
SharonS2 - Fri Jul 19 12:39:12 EDT 2013

abe777 - Fri Jul 19 11:31:27 EDT 2013

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

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!

Re: Importing Word Tables as OLE Objects
abe777 - Fri Jul 19 13:36:49 EDT 2013

SharonS2 - Fri Jul 19 12:39:12 EDT 2013

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!

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

Add_Macro.txt
DXL Macro.rtf

Re: Importing Word Tables as OLE Objects
SharonS2 - Fri Jul 19 15:52:09 EDT 2013

abe777 - Fri Jul 19 13:36:49 EDT 2013

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

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

Re: Importing Word Tables as OLE Objects
dadere69 - Wed Nov 27 09:08:48 EST 2013

SharonS2 - Fri Jul 19 15:52:09 EDT 2013

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

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

Re: Importing Word Tables as OLE Objects
dhars_priya - Thu May 21 01:20:26 EDT 2015

abe777 - Fri Jul 19 10:47:41 EDT 2013

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

hi abe,

Is it possible to reverse the process what u did? I need to change the ole objects to normal table while exporting DOORS module(containing ole objects) to microsoft word(normal table).