Skip to content

Commit bbd3821

Browse files
committed
Close #2111
1 parent 7855e3c commit bbd3821

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Rubberduck.VBEEditor/Extensions/VBComponentsExtensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ public static void ImportSourceFile(this VBComponents components, string filePat
4747
var codeLines = codeString.Split(new []{Environment.NewLine}, StringSplitOptions.None);
4848
if (ext == VBComponentExtensions.DocClassExtension)
4949
{
50-
var component = components.Item(name);
51-
if (component != null)
50+
try
5251
{
52+
var component = components.Item(name);
5353
component.CodeModule.Clear();
5454
component.CodeModule.AddFromString(codeString);
5555
}
56+
catch (IndexOutOfRangeException) { } // component doesn't exist
5657
}
5758
else if (ext == VBComponentExtensions.FormExtension)
5859
{

0 commit comments

Comments
 (0)