7,785
社区成员




在查找如何用VB打开一个文档的时候,在评论区看到了大神的回复,我想知道这些代码是什么意思呀,求求,很急!!!
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Command1_Click()
Dim file As String
file = "help.doc"
ShellExecute 0, "open", file, vbNullString, vbNullString, 5
End Sub
上面的代码打开不了文档
如果要打开word文档,需要安装Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop
Module Module1
Sub Main()
' 创建Word应用程序实例
Dim wordApp As New Word.Application()
' 设置为可见
wordApp.Visible = True
' 打开指定的Word文档
Dim doc As Word.Document = wordApp.Documents.Open("C:\\Users\\zhour\\Documents\\点击.docx")
' 在此处添加代码以处理文档
End Sub
End Module