Skip to content

Commit 12f5b5d

Browse files
committed
Merge pull request #455 from Hosch250/next
Defuse bomb
2 parents 3be7706 + 33bfede commit 12f5b5d

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
@@ -74,8 +74,12 @@ public static void ExportAsSourceFile(this VBComponent component, string directo
7474
string filePath = Path.Combine(directoryPath, component.Name + component.Type.FileExtension());
7575
if (component.Type == vbext_ComponentType.vbext_ct_Document)
7676
{
77-
var text = component.CodeModule.get_Lines(1, component.CodeModule.CountOfLines);
78-
File.WriteAllText(filePath, text);
77+
int lineCount = component.CodeModule.CountOfLines;
78+
if (lineCount > 0)
79+
{
80+
var text = component.CodeModule.get_Lines(1, lineCount);
81+
File.WriteAllText(filePath, text);
82+
}
7983
}
8084
else
8185
{

0 commit comments

Comments
 (0)