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 Form_Load() ShellExecute Me.hwnd, "open", App.Path & "\1.doc", vbNullString, vbNullString, SW_SHOWNORMAL Me.Hide End Sub
答老张: 是help.doc,其实这不是主要问题。你写的东西有点复杂,对于我这个初学者有一些难度,你能不能按我下面的格式重新写一下代码,十分感谢!Private Sub help_Click() Shell "C:\Program Files\Microsoft Office\office11\winword.exe D:\我的文档\大作业\help.doc", 1 End Sub
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
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 这句话具体啥意思我不知道,但它在编译时出现了错误,说在“End sub,End function或End 属性后面只能出现注释”,能不能给我写一段直接可以用的代码啊?拜托各位大侠了……
谢谢,感觉你是个高手,^-^ 但是这两个工程怎么联系起来啊,我想通过单击来触发这个动作,可不可以这样想(恕我愚昧): Private Sub help_Click() 工程2.Form1.Show (刚才试了好像不行) End Sub工程2的代码(按你写的): 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 Form_Load() ShellExecute Me.hwnd, "open", App.Path & "\help.doc", vbNullString, vbNullString, SW_SHOWNORMAL Me.Hide End Sub是这样理解么?
'单击打开 Private Sub help_Click() ShellExecute Me.hwnd, "open", App.Path & "\help.doc", vbNullString, vbNullString, SW_SHOWNORMAL Me.Hide End Sub
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 -----这个拷过来没有?拷过来放在最上边.
先引用OFFICE-WORD DLL Dim wordApp As New Word.Application Dim wordDoc As New Word.Document Set wordApp = CreateObject("Word.Application") '½¨Á¢WORDʵÀý wordApp.Visible = False 'ÆÁ±ÎWORDʵÀý´°Ìå Set wordDoc = wordApp.Documents.Open(FileName) '´ò¿ªÎļþ²¢¸³ÓèÎļþʵÀý
Shell (App.Path + "\1.DOC")
End Sub关于shell这个函数我们学的不多,希望大侠们指教了。
Shell "C:\Program Files\Microsoft Office\office11\winword.exe D:\我的文档\大作业\help.doc", 1
请问,怎么改为相对路径啊?
求助啊,今天就要交作业了啊!
Private Sub Form_Load()
ShellExecute Me.hwnd, "open", App.Path & "\1.doc", vbNullString, vbNullString, SW_SHOWNORMAL
Me.Hide
End Sub
是help.doc,其实这不是主要问题。你写的东西有点复杂,对于我这个初学者有一些难度,你能不能按我下面的格式重新写一下代码,十分感谢!Private Sub help_Click()
Shell "C:\Program Files\Microsoft Office\office11\winword.exe D:\我的文档\大作业\help.doc", 1
End Sub
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
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 这句话具体啥意思我不知道,但它在编译时出现了错误,说在“End sub,End function或End 属性后面只能出现注释”,能不能给我写一段直接可以用的代码啊?拜托各位大侠了……
谢谢,感觉你是个高手,^-^
但是这两个工程怎么联系起来啊,我想通过单击来触发这个动作,可不可以这样想(恕我愚昧):
Private Sub help_Click()
工程2.Form1.Show (刚才试了好像不行)
End Sub工程2的代码(按你写的):
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 Form_Load()
ShellExecute Me.hwnd, "open", App.Path & "\help.doc", vbNullString, vbNullString, SW_SHOWNORMAL
Me.Hide
End Sub是这样理解么?
Private Sub help_Click()
ShellExecute Me.hwnd, "open", App.Path & "\help.doc", vbNullString, vbNullString, SW_SHOWNORMAL
Me.Hide
End Sub
-----这个拷过来没有?拷过来放在最上边.
你创建一个文件夹(文件夹名任取),在其中新建一个Word文件(取名help.doc),打开vb6.0,新建"工程1"(保存时一定要与help.doc放在同一文件夹内),将上面的代码复制到form1中去,并在该窗体上添加一个"Command1"。好了,就这么简单。
Dim wordApp As New Word.Application
Dim wordDoc As New Word.Document
Set wordApp = CreateObject("Word.Application") '½¨Á¢WORDʵÀý
wordApp.Visible = False 'ÆÁ±ÎWORDʵÀý´°Ìå
Set wordDoc = wordApp.Documents.Open(FileName) '´ò¿ªÎļþ²¢¸³ÓèÎļþʵÀý