第1个回答 2010-04-01
Option Explicit
Private Sub command1_click() '单击
Shell "explorer " & App.Path & "", 1
End Sub
我试过了···可以的···呵呵
回复:不懂就问不怕问
请看清楚,我这个就是那个应用程序在哪里就打开那个应用程序文件夹而不是应用程序的方法··· 和其他的都不一样的···修改了下我就排在在这么下面了··呼呼··
回复:不懂就问不怕问
被不懂就问不怕问说了下,我再看了下题目发觉越来越混了··
楼主说,把那个文件放在一个任意文件夹里,可以让它打开名为 1.exe 的文件。而根据他的截图来说是此程序所在文件夹下的文件。那不是只要Shell App.Path & "\a.exe"就好了?
第2个回答 2010-03-31
以下代码可以打开当前目录下所有注册类型的文件:
Private Sub Command1_Click()
Dim S As String
Const Sh As String = "rundll32 url.dll,FileProtocolHandler ""#"""
S =app.path & "\xxx.xx" '请把xxx.xx修改为具体的文件名,其他代码不要改
Shell Replace(Sh, "#", S) '打开
End Sub本回答被提问者采纳
第3个回答 2010-03-27
shell "start " & app.path & "\a"
这里的start意思就是可以用系统默认程序打开非可执行格式
app.path返回生成文件所在目录(这个据说一定要生成exe才能用),不包括"\"
所以在最后加上
a就是你的文件了
还有任何不明白找我,我的QQ1120212213
第4个回答 2010-03-27
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Private Sub command1_Click()
Dim ofn As OPENFILENAME
Dim rtn As String
ofn.lStructSize = Len(ofn)
ofn.hwndOwner = Me.hWnd
ofn.hInstance = App.hInstance
ofn.lpstrFilter = "所有文件"
ofn.lpstrFile = Space(254)
ofn.nMaxFile = 255
ofn.lpstrFileTitle = Space(254)
ofn.nMaxFileTitle = 255
ofn.lpstrInitialDir = App.Path
ofn.lpstrTitle = "打开文件"
ofn.flags = 6148
rtn = GetOpenFileName(ofn)
If rtn >= 1 Then
Me.Caption = ofn.lpstrFile
Else
Me.Caption = "Cancel Was Pressed"
End If
Shell Me.Caption, vbNormalFocus
End Sub
添加一个按钮。复制上面代码