大家快帮我看看这段代码啊!

fanyang111 2004-04-30 03:42:51
类模块有myword,mydoc的定义:
窗体代码如下:
for i=1 to 10
Set mydoc = myword.Documents.Open(......)'文档名和I有关!
Set mytable = mydoc.Tables(1)
mydoc.Saved = True 'true代表不保存
mydoc.PrintOut
mydoc.Close
Set mydoc = Nothing
Set myword = Nothing
myword.Quit
next i

现在问题是这样的!每个循环都会在系统后台产生一个winword的进程(按下 Ctrl+Alt+Del 查看), 这样的话最终会导致系统死机!可是我不明白的是为什么我都set nothing 了!怎么还会有winword的进程啊?哪位高手帮忙解答一下哦!
...全文
72 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yenight 2004-05-05
  • 打赏
  • 举报
回复
学习!!
沐NeMo 2004-05-05
  • 打赏
  • 举报
回复
你把myword.Quit放在Set mydoc = Nothing前面:
mydoc.Quit
Set mydoc = Nothing
myword是在用FOR之前就有新建的一个进程吧,这也就要在for这后kill掉myword.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
for i=1 to 10
Set mydoc = myword.Documents.Open(......)'文档名和I有关!
Set mytable = mydoc.Tables(1)
mydoc.Saved = True 'true代表不保存
mydoc.PrintOut
mydoc.Close
mydoc.Quit
Set mydoc = Nothing
next i
myword.Quit
Set myword = Nothing

fanyang111 2004-05-05
  • 打赏
  • 举报
回复
楼上的:quit如果在set nothing 之前 就会弹出一个对话框
”word正在打印,如果退出word就会取消尚未完成的作业!“

2,503

社区成员

发帖
与我相关
我的任务
社区描述
VBA(Visual Basic for Applications)是Visual Basic的一种宏语言,是在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。
社区管理员
  • VBA
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧