从Excel中获取Word中的图片名称

时间:2017-04-24 11:53:22

标签: excel vba excel-vba ms-word word-vba

使用Excel VBA,我需要在Active Word文档中获取图片的名称。

这是我使用的代码:

Dim WordApp As Object
Dim DocumentoDestino As Object
Set DocumentoDestino = WordApp.ActiveDocument    
MsgBox DocumentoDestino.Shapes(1).Name

还有:

Dim WordApp As Object
Dim DocumentoDestino As Object
Set DocumentoDestino = WordApp.ActiveDocument    
MsgBox DocumentoDestino.InlineShapes(1).Name

但这些都不起作用。

错误消息为" 438: Object doesn't support this property or method"。

1 个答案:

答案 0 :(得分:0)

您需要先创建WordApp对象。

Dim WordApp As Word.Application
Dim DocumentoDestino As Document

Set WordApp = CreateObject("word.Application")
Set DocumentoDestino = WordApp.ActiveDocument