2、需要将drivelistbox、dirlistbox、filelistbox结合起来用,双击运行filelistbox中的xls文档: Private Sub Dir1_Change() File1.Path = Dir1.Path End SubPrivate Sub Drive1_Change() Dir1.Path = Drive1.Drive End SubPrivate Sub File1_DblClick() Shell Dir1.Path & "\" & File1.FileName End SubPrivate Sub Form_Load() File1.Pattern = "*.xls" End Sub
不能打开xls文件啊???是怎么回事?代码正确吗??
不能覆盖任务栏的原因:你的窗体的borderstyle属性设置为0-none了没有? 不能打开xls文件的原因:是我写错了代码,应该用shellexecute: 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 Longshellexecute me.hwnd,"open",Dir1.Path & "\" & File1.FileName,,,vbnormalfocus
me.move 0,0,screen.width,screen.height
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End SubPrivate Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End SubPrivate Sub File1_DblClick()
Shell Dir1.Path & "\" & File1.FileName
End SubPrivate Sub Form_Load()
File1.Pattern = "*.xls"
End Sub
不能打开xls文件的原因:是我写错了代码,应该用shellexecute:
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 Longshellexecute me.hwnd,"open",Dir1.Path & "\" & File1.FileName,,,vbnormalfocus
File1.FileName,,,vbnormalfocus”
这句代码系统提示有问题!
2、如果是磁盘根目录下面的xls文件,就是shellexecute me.hwnd,"open",Dir1.Path & File1.FileName,,,vbnormalfocus
如果不是上面的两个原因,就把提示的错误信息发上来看看。