VBS 选择文件/文件夹对话框


Function SelectFile()
	Set oExec = CreateObject("WScript.Shell")._
	Exec("mshta.exe ""about:<input type=file id=path><script>path.click();new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(path.value);close();resizeTo(0,0);</script>""")
	StrLine = oExec.StdOut.ReadAll
	Pos = InStr(StrLine, Chr(13))
	If Pos <= 0 Then
		SelectFile = ""
	Else
		SelectFile = Left(StrLine, Pos - 1)
	End If
End Function

Function SelectFolder(default)
	If IsNull(default) Then
		default = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
	End If
	Set Folder = CreateObject("Shell.Application").BrowseForFolder(0, "", 0, default)
	If Folder Is Nothing Then
		SelectFolder = ""
	Else
		SelectFolder = Folder.Self.Path
	End If
End Function

MsgBox SelectFile()
MsgBox SelectFolder(Null)

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM