标签:io ar os sp java for 文件 on cti
第一种:
Function BrowseForFile()
Dim shell : Set shell = CreateObject("WScript.Shell")
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim tempFolder : Set tempFolder = fso.GetSpecialFolder(2)
Dim tempName : tempName = fso.GetTempName()
Dim tempFile : Set tempFile = tempFolder.CreateTextFile(tempName & ".hta")
tempFile.Write _
"<html>""<head>""<title>Browse</title>""</head>" & _
"<body>" & _
"<input type=‘file‘ id=‘f‘ />" & _
"<script type=‘text/javascript‘>" & _
"var f = document.getElementById(‘f‘);" & _
"f.click();" & _
"var shell = new ActiveXObject(‘WScript.Shell‘);" & _
"shell.RegWrite(‘HKEY_CURRENT_USER\\Volatile Environment\\MsgResp‘, f.value);" & _
"window.close();" & _
"</script>" & _
"</body>" & _
"</html>"
tempFile.Close
shell.Run tempFolder & "\" & tempName & ".hta", 0, True
BrowseForFile = shell.RegRead("HKEY_CURRENT_USER\Volatile Environment\MsgResp")
shell.RegDelete "HKEY_CURRENT_USER\Volatile Environment\MsgResp"
End Function
MsgBox BrowseForFile()
第二种:
dim oShell
set oShell = CreateObject("Shell.Application")
oShell.MinimizeAll ‘ 最小化所有窗口
oShell.FindFiles ‘ 打开文件搜索窗口
oShell.Explore "F:\" ‘ i浏览文件夹
oShell.BrowseForFolder 0,"请为程序选择一个文件夹",0x1000|0x0001,0x0000
第三种:
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Navigate "About:Blank"
oIE.Document.Write "<INPUT TYPE=‘file‘ ID=‘x‘ />"
Set oElement = oIE.Document.getElementById("x")
oElement.Click
WScript.Echo oElement.Value
oIE.Quit
标签:io ar os sp java for 文件 on cti
原文地址:http://www.cnblogs.com/futrueface/p/4123387.html