Skip to content

Commit 33bfede

Browse files
committed
Defuse bomb
1 parent 68b257f commit 33bfede

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

RetailCoder.VBE/VBA/VBComponentExtensions.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,12 @@ public static void ExportAsSourceFile(this VBComponent component, string directo
7373
string filePath = Path.Combine(directoryPath, component.Name + component.Type.FileExtension());
7474
if (component.Type == vbext_ComponentType.vbext_ct_Document)
7575
{
76-
var text = component.CodeModule.get_Lines(1, component.CodeModule.CountOfLines);
77-
File.WriteAllText(filePath, text);
76+
int lineCount = component.CodeModule.CountOfLines;
77+
if (lineCount > 0)
78+
{
79+
var text = component.CodeModule.get_Lines(1, lineCount);
80+
File.WriteAllText(filePath, text);
81+
}
7882
}
7983
else
8084
{

0 commit comments

Comments
 (0)