![]() |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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] |
|
#3
|
|||
|
|||
|
Hi,
Thanks so much. It worked. ![]() ![]() ![]() Cheers, Tomato. |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Macro to convert table to convert table into iCalendar file?
|
Weboh | Word VBA | 5 | 12-10-2016 03:07 PM |
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 equation objects to inline objects
|
sumjoh | Word VBA | 1 | 01-29-2013 08:38 PM |
Shape Objects
|
Space Cowboy | PowerPoint | 4 | 10-04-2010 07:14 PM |