![](/img/trans.png)
[英]How to determine if 'SaveChanges:=wdDoNotSaveChanges' was passed to Interop.Word.Document.Close()
[英]How to close a word document
當我運行此應用程序時,文檔打開正常但它不會關閉並使文檔保持打開狀態。 如何正確關閉單詞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
也許,你想在最后關閉Word應用程序? 嘗試這個:
AppWord.Quit
使用shell函數關閉它(taskkill)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.