在EXCEL窗体,CommandButton1中输入代码:
Private Sub CommandButton1_Click()
Dim wordapp As New Word.Application
Dim worddoc As New Word.Document
Set wordapp = CreateObject("Word.Application")
wordapp.Visible = True
Set worddoc = wordapp.Documents.Open(ThisWorkbook.Path & "\123.docx")
MsgBox "文件已打开,名字为:" & worddoc
End Sub
如果打开会提示“文件已打开,名字为123.doc”
操作前把这个引用起:
有测试附件,你可以试一下;