I have a word vba that uses excel and has several procedures that call:
private sub testsub1
'some process
call testsub2 (a, b, c,...)
end sub
private sub testsub2 (byref a as long, byref b as long, byref c as long,...)
'some process
call testsub3 (a, b, c,...)
end sub
private sub testsub3 (byref a as long, byref b as long, byref c as long,...)
'some process
'calls testub2 if a is less than some value.
if a < somevalue then
call testsub2 (a, b, c,...)
end if
documents("doc1").close 'closes a document
wb.close 'closes a workbook
exc.quit 'closes excel
set wb = nothing
set exc = nothing
msgbox "Analysis complete"
end sub
Question: I cannot end sub in testsub3 after calling testsub2 from testsub3. After MsgBox, it jumps to some code in testsub3 (documents("doc1").close)---error: bad file name ------>document has already been closed.
But I am able to end if it did not call testsub2.
Ideas?
Thanks
Note: I don't use loop because the code is too long (error: procedure is too large). Hence the multiple procedures/sub.