[ad_1]
I am new to vba and I have a question. I have written a macro in word to open and save embedded documents in the active document. The code I wrote is below:
Sub Extract()
Dim num As Integer
Dim AD As Document
Set AD = ActiveDocument
Dim numObjects As Integer
numObjects = AD.InlineShapes.Count
'MsgBox numObjects ' prints "11"
For num = 1 To numObjects
If AD.InlineShapes(num).Type = 1 Then
'it's an embedded OLE type so open it.
AD.InlineShapes(num).OLEFormat.Open
AD.InlineShapes(num).OLEFormat.Object.SaveAs FileName:="C:UsersAnkitaDesktopNew folderx.xlsx", FileFormat:=51
End If
Next num
End Sub
What I would like to do is extract all embedded documents in all the word documents present in a source folder and save all of them in a destination folder.
I understand that I would have to access the word docs and loop through them and have the same code snippet as above, but how exactly do I write it.
Any help would be appreciated.
[ad_2]
لینک منبع