Thread: [Solved] Convert Ole objects
View Single Post
 
Old 05-05-2020, 07:39 PM
Tomato Tomato is offline Windows 10 Office 2010
Novice
 
Join Date: May 2020
Posts: 2
Tomato is on a distinguished road
Default Convert Ole objects

Hi there,

I have ole objects embedded in a word file.
To be able to edit the ole objects (word tables) I need to double click on them and another instance of word opens. This is a lot of work.

Thus, I would like to convert them to word object in one macro run that I can edit them easily.


The following macro works only if you right click on each object and do object convert to Microsoft Word Macro-Enabled Document before you run the macro.
When you run the script it is only converting the one you have applied the conversion.
However, I would like to run a macro ones and all objects are converted.


Macro:

Code:
Sub Convert_Ole_to_Word()
    Dim DocA As Document
    Dim DocB As Document
    Dim ilsh As InlineShape
    Dim rngB As Range
    Dim rngA As Range
 
    Set DocA = ActiveDocument
    For Each ilsh In DocA.InlineShapes
        If InStr(1, ilsh.OLEFormat.ProgID, "Word.Document", vbTextCompare) = 1 Then
           Set DocB = ActiveDocument.InlineShapes(1).OLEFormat.Object
            Set rngA = ilsh.Range
            If DocB.Tables.Count = 1 Then
                Set rngB = DocB.Tables(1).Range
                rngB.Copy
                ilsh.Delete
                rngA.Paste
            End If
        End If
    Next ilsh
End Sub

Much appreciated if you could help and modify the macro?

Many thanks.
Regards,
T.

Last edited by macropod; 05-05-2020 at 09:26 PM. Reason: Added code tags
Reply With Quote