如何关闭在后台运行的 winword.exe(使用了 Interop) [英] how to close a winword.exe that runs in the background (Interop was used)
问题描述
我在 vb 中创建了一个 word 文档,但问题是每次单击我的按钮时都会打开一个新文档.我尝试了以下代码在它完成后终止它目的但似乎没有任何效果我搜索了多个网站,但没有找到有帮助的答案我使用了互操作
i created a word doc in vb but the problem is each time my button is clicked it opens a new doc. i have tried the following code to terminate it after it fulfilled its purpose but nothing seems to work and i have search multiple sites but found no answer that helped i used interop
我试图关闭后台 winword.exe(objDoc 是单词 doc)
my attempts to close the background winword.exe (objDoc is the the word doc )
objDoc.Close()
objDoc.Application.Quit()
objDoc.Application.DDETerminateAll()
GC.Collect()
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(objDoc)
是的,我确实看过这个网站上关于关闭互操作词应用程序的帖子,但它失败了,所以我对任何新想法持开放态度
and yes i did look at the post on this site about closing interop word applications but its fails so i am open to any new ideas
推荐答案
您正在关闭 objdoc 而不是 objWord
you are closing the objdoc instead of objWord
objDoc.Close()
objWord.Application.Quit(False)
objWord = Nothing
这篇关于如何关闭在后台运行的 winword.exe(使用了 Interop)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!