|
1、添加一个模块,声明函数
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
2、在窗体添加按钮,在click中写入如下代码
Dim sfile As String
sfile = App.Path & "你的MDB文件名.mdb" '在与可执行文件在同一目录,其它类似
lR = ShellExecute(Me.hwnd, "open", sfile, "", "", VB窗体标题)
If (lR < 0) Or (lR > 32) Then '打开成功
'Unload Me
Else
MsgBox "系统文件丢失或损坏!" & Chr(10) & Chr(13) & "请与系统管理员或开发商联系统!", vbInformation, "文件出错"
End If
3、注意事项:你的机子必须安装有ACCESS,因为ShellExecute 函数是自动调用文件关联的
|
|