In this link , i use SHP.OnAction
(where Dim SHP As Shape
) to print the name of the macro which is assigned to a shape.
Now I would like to check if SHP.OnAction
is empty, which means there is no macro assigned to this object. SHP.OnAction = ""
does not work, it always return false
. I have tried also ``SHP.OnAction = Empty ,
SHP.OnAction = Null , they always return
false` too...
Could anyone tell me how to verify if it is empty?
Edit1: I use the following piece of code, to go through all the shapes in a workbook, and check if there is a shape to that a macro is assigned. I test it with some workbooks containing Chart
or Picture
, it seems that sShpaes.OnAction <> ""
returns always true
, even though the shape has no macro...
On Error Resume Next
Dim sShapes As Shape
existsAssignedShape = False
For Each ws In Worksheets
For Each sShapes In ws.Shapes
st = ws.Name & " " & sShapes.Name & " " & sShapes.OnAction
Print #1, st
Print #1, ""
If (Not existsAssignedShape) And (sShpaes.OnAction <> "") Then
existsAssignedShape = True
End If
Next sShapes
Next ws
If no macro has been assigned to an AutoShape, then the following will indicate True :
Sub hgfd()
Dim s As Shape, t As String
Set s = ActiveSheet.Shapes(1)
t = CStr(s.OnAction)
MsgBox t = ""
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.