VBA,电子表格,如何用按钮事件打开一个文件夹?

如题所述

第1个回答  推荐于2017-09-18
Private Sub CommandButton1_Click() Dim Obj As Object, Path1
Set Obj = CreateObject("shell.application")
Set Path1 = Obj.BrowseForFolder(0, "选择要打开的文件夹:", 0)
If Not Path1 Is Nothing Then
Obj.Open (Path1.self.Path)
End If
End Sub
第2个回答  推荐于2017-10-02
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

'Api直接看Api浏览器就可以调出来了
Sub A2()
ShellExecute Application.hwnd, "Open", "路径", "", "", vbNormalFocus
End Sub

Sub A1()
'Shell函数
Shell "Explorer " & "路径", vbNormalFocus
End Sub追问

我说的是打开电子表格,而且是VBA

追答

这不就是Vba了咯,VBA也不过是引用VB的

本回答被提问者采纳
第3个回答  2013-02-07
点击一下含有下面的函数的单元格,可用函数可以打开文件夹:
=hyperlink(文件夹地址,"需要显示的提示内容")
相似回答