@@ -52,22 +52,25 @@ private static string GetDisplayName(VBProject project)
52
52
// Eg. A PowerPoint Slide is top level, but it's parent is a Presentation (that is NOT a vbComponent)
53
53
try
54
54
{
55
- var parentProp = project . VBComponents . Cast < VBComponent > ( )
55
+ var firstOrDefault = project . VBComponents . Cast < VBComponent > ( )
56
56
. FirstOrDefault ( comp => comp . Type == vbext_ComponentType . vbext_ct_Document
57
- && comp . Properties . Item ( "Parent" ) . Value != null )
58
- . Properties . Cast < Property > ( ) . FirstOrDefault ( property => property . Name == "Parent" ) ;
59
-
60
- Properties props = null ;
61
- Property nameProperty = null ;
62
- if ( parentProp . Value is Properties )
57
+ && comp . Properties . Item ( "Parent" ) . Value != null ) ;
58
+ if ( firstOrDefault != null )
63
59
{
64
- props = ( Properties ) parentProp . Value ;
65
- nameProperty = props . Cast < Property > ( ) . FirstOrDefault ( property => property . Name == "Name" ) ;
60
+ var parentProp = firstOrDefault
61
+ . Properties . Cast < Property > ( ) . FirstOrDefault ( property => property . Name == "Parent" ) ;
62
+
63
+ Property nameProperty = null ;
64
+ if ( parentProp != null && parentProp . Value is Properties )
65
+ {
66
+ var props = ( Properties ) parentProp . Value ;
67
+ nameProperty = props . Cast < Property > ( ) . FirstOrDefault ( property => property . Name == "Name" ) ;
68
+ }
69
+
70
+ return nameProperty == null
71
+ ? null
72
+ : nameProperty . Value . ToString ( ) ;
66
73
}
67
-
68
- return nameProperty == null
69
- ? null
70
- : nameProperty . Value . ToString ( ) ;
71
74
}
72
75
catch
73
76
{
0 commit comments