excel vba Loop through all shapes in a workbook

The solution for “excel vba Loop through all shapes in a workbook” can be found here. The following code will assist you in solving the problem.

‘ —————————————————————-
‘ Purpose: Loop through all shapes on all sheets in a workbook
‘ —————————————————————-
Sub loopShapesAllSheet()

Dim shp As Shape
Dim sh As Worksheet

‘Loop through all the sheets in a workbook
For Each sh In ThisWorkbook.Worksheets

‘If there is any shape on the sheet
If sh.Shapes.Count > 0 Then
‘Loop through all the shapes on the sheet
For Each shp In sh.Shapes

‘Print to immediate window shape type, shape name and sheet name holding the shape
‘Useful link: https://msdn.microsoft.com/en-us/VBA/Office-Shared-VBA/articles/msoshapetype-enumeration-office
Debug.Print shp.Type & vbTab & shp.Name & vbTab & shp.Parent.Name

Next shp
End If
Next sh
End Sub

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts