[英]How to close a word document
When I run this application, the document opens fine but it doesn't close and leaves the document open. 当我运行此应用程序时,文档打开正常但它不会关闭并使文档保持打开状态。 How can I close the word doc properly? 如何正确关闭单词doc?
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim AppWord = CreateObject("Word.Application")
Dim WordDoc = CreateObject("Word.Document")
Dim filename As String
Dim result As String
filename = "C:\Users\Business\Desktop\Test.docx"
WordDoc = AppWord.Documents.Open(filename)
txtFileContents.Text = WordDoc.Content.Text
WordDoc.Close()
End Sub
Perhaps, you want to close the Word app at the end? 也许,你想在最后关闭Word应用程序? Try this: 尝试这个:
AppWord.Quit
使用shell函数关闭它(taskkill)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.