【发布时间】:2014-01-04 02:21:11
【问题描述】:
我有一个词vba,它使用excel,并且有几个程序调用:
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
问题:从 testsub3 调用 testsub2 后,我无法在 testsub3 中结束 sub。在 MsgBox 之后,它跳转到 testsub3 中的一些代码 (documents("doc1").close)---error: bad file name ------>document has already been closed。
但如果它没有调用 testsub2,我可以结束。
想法?
谢谢
注意:我不使用循环,因为代码太长(错误:过程太大)。因此,多个程序/子。
【问题讨论】:
-
循环在这里不起作用。代码太长,无法放入一个循环 - 导致错误:过程太大。这就是我创建多个潜艇的原因。