VBA 形状对象
VBA Shape Objects
我从互联网上提取了这段代码。出于某种原因,我在 For Each objShape In reportDoc.Shapes
行收到 'type mismatch' 错误。也许原因非常非常明显,但我不知道为什么。
如有任何帮助,我们将不胜感激。
Sub UseTextBox()
Dim objShape As Shape
Dim reportDoc As Object
Set reportDoc = ActiveDocument
MsgBox reportDoc
For Each objShape In reportDoc.Shapes
If objShape.Type = msoTextBox Then
MsgBox TextFrame.TextRange
End If
Next objShape
End Sub
我已经测试了你的代码。我没有收到 'type mismatch' 错误,但出现编译错误:
MsgBox TextFrame.TextRange
应该是
MsgBox objShape.TextFrame.TextRange
我从互联网上提取了这段代码。出于某种原因,我在 For Each objShape In reportDoc.Shapes
行收到 'type mismatch' 错误。也许原因非常非常明显,但我不知道为什么。
如有任何帮助,我们将不胜感激。
Sub UseTextBox()
Dim objShape As Shape
Dim reportDoc As Object
Set reportDoc = ActiveDocument
MsgBox reportDoc
For Each objShape In reportDoc.Shapes
If objShape.Type = msoTextBox Then
MsgBox TextFrame.TextRange
End If
Next objShape
End Sub
我已经测试了你的代码。我没有收到 'type mismatch' 错误,但出现编译错误:
MsgBox TextFrame.TextRange
应该是
MsgBox objShape.TextFrame.TextRange