Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-05-2020, 07:39 PM
Tomato Tomato is offline Convert Ole objects Windows 10 Convert Ole objects Office 2010
Novice
Convert Ole objects
 
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
  #2  
Old 05-05-2020, 09:50 PM
macropod's Avatar
macropod macropod is offline Convert Ole objects Windows 7 64bit Convert Ole objects Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub ConvertTblObjs()
Application.ScreenUpdating = False
Dim i As Long
With ActiveDocument
  For i = .InlineShapes.Count To 1 Step -1
    With .InlineShapes(i)
      If Not .OLEFormat Is Nothing Then
        If Split(.OLEFormat.ClassType, ".")(0) = "Word" Then
          .OLEFormat.Object.Tables(1).Range.Copy
          .Range.Paste
        End If
      End If
    End With
  Next
End With
Application.ScreenUpdating = True
MsgBox "Finished processing!"
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-05-2020, 10:03 PM
Tomato Tomato is offline Convert Ole objects Windows 10 Convert Ole objects Office 2010
Novice
Convert Ole objects
 
Join Date: May 2020
Posts: 2
Tomato is on a distinguished road
Default

Hi,
Thanks so much. It worked.

Cheers,
Tomato.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Ole objects Macro to convert table to convert table into iCalendar file? Weboh Word VBA 5 12-10-2016 03:07 PM
Convert Ole objects Macros to move objects prevents moving same objects with arrow keys BruceM Word VBA 1 03-10-2015 08:20 AM
I want to create objects that are seen and but will not print - even with Print Drawing Objects On Darlin Nicky Word 6 02-10-2015 02:52 PM
Convert Ole objects Convert equation objects to inline objects sumjoh Word VBA 1 01-29-2013 08:38 PM
Convert Ole objects Shape Objects Space Cowboy PowerPoint 4 10-04-2010 07:14 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:52 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft