我正在尝试在Word中编写一些VBA代码,该代码可以提取Word文档中的嵌入式.txt文件并将其保存到指定的文件夹中。
我对VBA不太熟悉,我尝试修改此脚本,但未成功: 任何帮助表示赞赏!
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:\Users\Public\test.txt", FileFormat:=42
End If
Next num
结束子