编了一个程序,弄了一个帮助文档"help.doc"
想通过单击事件打开这个word文档,因为是要交给老师的,所以要用相对路径,请问各位VB高手,怎么实现它?
希望论坛上的各位高手能够帮助一下小弟。
想通过单击事件打开这个word文档,因为是要交给老师的,所以要用相对路径,请问各位VB高手,怎么实现它?
希望论坛上的各位高手能够帮助一下小弟。
解决方案 »
- 图片隐藏的问题
- 求助 ListView 可不可以选中 某一个格,可以怎么实现?
- 现在VB6的程序员为什么这么难招?郁闷中...散分
- vb中有没有计算一段时间内,有多少个周日的函数量啊?或者是查今天是不是周日的函数?
- 关于数据库编程 包括 帐户 密码 登陆按纽 在线等!急急急
- 在VB中怎样判断与SQLSERVER数据库的连接状态,若断开了,怎样回复?
- 有谁知道SQL Server2000的安装序列号?谢谢
- 不好意思,简单问题没搞定
- 请问怎么用adodc打开一个有密码的access库?
- 怎样实现鼠标左键点击事件????48分..
- vb关于option的使用!
- 关于VB全盘搜索指定EXE文件并打开的问题。请能人解决!谢谢。
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) '´ò¿ªÎļþ²¢¸³ÓèÎļþʵÀý