【发布时间】:2014-03-22 22:10:34
【问题描述】:
我正在寻找编写 VBA 以将嵌入的文件保存在 Word 文档中。但是我在打开它们时遇到了问题:
Sub Extract()
Dim num as Integer
Dim numObjects As Integer
numObjects = ActiveDocument.InlineShapes.count
MsgBox numObjects ' prints "11"
For num = 1 To numObjects
If ActiveDocument.InlineShapes(num).Type = 1 Then
'it's an embedded OLE type so open it.
ActiveDocument.InlineShapes(num).OLEFormat.Open
'Works for the first one but errors 5941 (the requested
' member of the collection does not exist)
End If
Next num
End Sub
如果第一个嵌入文件尚未打开,此代码将打开它。它在下一个错误。
或者,如果第一个文件已经打开,宏似乎什么都不做。
有什么提示吗? (我正在使用 Word 2010 执行此操作。)
【问题讨论】:
标签: vba error-handling reference ms-word