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