如何关闭word文档

时间:2014-03-23 23:19:30

标签: vb.net visual-studio vb6

当我运行此应用程序时,文档打开正常,但它不会关闭并使文档保持打开状态。如何正确关闭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

2 个答案:

答案 0 :(得分:4)

也许,你想在最后关闭Word应用程序?试试这个:

AppWord.Quit

答案 1 :(得分:-1)

使用shell函数关闭它(taskkill)