引用CommonDialog和Microsoft Word 11.0 object Libary(其他版本也行,看機器情況)
Private Sub Command1_Click()
Dim DocPath As String
Dim wApp As New Word.Application
CommonDialog1.ShowOpen
DocPath = CommonDialog1.FileName
If DocPath = "" Then wApp.Documents.Close: Set wApp = Nothing
wApp.Documents.Open DocPath
wApp.Visible = True
End Sub
Private Sub Form_Load()
CommonDialog1.Filter = "Word文件 (*.dco)|*.doc"
CommonDialog1.DialogTitle = "選擇要開啟的文件"
CommonDialog1.CancelError = False
引用CommonDialog和Microsoft Word 11.0 object Libary(其他版本也行,看機器情況)
Private Sub Command1_Click()
Dim DocPath As String
Dim wApp As New Word.Application
CommonDialog1.ShowOpen
DocPath = CommonDialog1.FileName
If DocPath = "" Then wApp.Documents.Close: Set wApp = Nothing
wApp.Documents.Open DocPath
wApp.Visible = True
End Sub
Private Sub Form_Load()
CommonDialog1.Filter = "Word文件 (*.dco)|*.doc"
CommonDialog1.DialogTitle = "選擇要開啟的文件"
CommonDialog1.CancelError = False
End Sub