濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > vbs,hta中選擇文件夾對(duì)話框?qū)崿F(xiàn)代碼

vbs,hta中選擇文件夾對(duì)話框?qū)崿F(xiàn)代碼

熱門(mén)標(biāo)簽:海外美發(fā)店地圖標(biāo)注 辦理膠州400電話財(cái)稅 前鋒辦理400電話申請(qǐng) 打電話的外呼系統(tǒng)貴不貴 陜西高頻外呼回?fù)芟到y(tǒng)哪家好 外呼營(yíng)銷下單系統(tǒng) 百度地圖標(biāo)注怎么卸載 新密防封卡外呼系統(tǒng)違法嗎 加盟電銷機(jī)器人好的品牌
復(fù)制代碼 代碼如下:

on error resume next
SelectFolder
function SelectFolder()
Const MY_COMPUTER = H11
Const WINDOW_HANDLE = 0
Const OPTIONS = 0
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(WINDOW_HANDLE, "選擇文加夾:", OPTIONS, strPath)
If objFolder Is Nothing Then
msgbox "您沒(méi)有選擇任何有效目錄!"
End If
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
msgbox "您選擇的文件夾是:" objPath
end function


但是這個(gè)代碼不能在hta里用,原因是權(quán)限不夠,不知道其它機(jī)子上能不能。
于是寫(xiě)了個(gè)用vbs自帶函數(shù)和fso結(jié)合的文件夾選擇代碼,僅供參考
復(fù)制代碼 代碼如下:

script language=vbscript>
dim spath
spath="Root"

function SFolder()
on error resume next
Dim fso, drv, f, fc, nf, s, i, p, r, d
i=3
if spath="Root" then
Set fso =CreateObject("Scripting.FileSystemObject")
Set drv =fso.Drives
s="輸入序號(hào)為進(jìn)入,序號(hào)+#為選中(c為取消)"+chr(13)+chr(10)
s=s+"1.根目錄"+chr(13)+chr(10)
s=s+"2.上層"+chr(13)+chr(10)
For Each a In drv
s=s+cstr(i)+"."+ a.Path+chr(13)+chr(10)
i=i+1
Next
GetD s
else
Set fso =CreateObject("Scripting.FileSystemObject")
if right(spath,1)>"\" then
spath=spath+"\"
end if
Set fc =fso.GetFolder(spath).SubFolders
s="輸入序號(hào)為進(jìn)入,序號(hào)+#為選中(c為取消)"+chr(13)+chr(10)
s=s+"1.根目錄"+chr(13)+chr(10)
s=s+"2.上層"+chr(13)+chr(10)
for each nf in fc
s=s+cstr(i)+"."+nf+chr(13)+chr(10)
i=i+1
next
GetF s
end if
end function

function GetD(s)
on error resume next
p=inputbox(s,"","")
if p="c" then
exit function
end if
r=split(s,chr(13)+chr(10))
if right(p,1)="#" then
if left(p,len(p)-1)=1 then
msgbox "這是根目錄,不能選擇根目錄!"
GetD s
elseif left(p,len(p)-1)=2 then
msgbox "這是根目錄,不能選擇根目錄!"
GetD s
else
d=split(r(left(p,len(p)-1)),".")
msgbox "選擇:" d(1)
Document.forms("ValidForm").FPath.Value=d(1)
spath="Root"
end if
else
if p=1 then
msgbox "已經(jīng)是根目錄!"
GetD s
elseif p=2 then
msgbox "已經(jīng)是最上層!"
GetD s
else
d=split(r(p),".")
spath=d(1)
'msgbox "進(jìn)入:" d(1)
SFolder
end if
end if
end function

function GetF(s)
on error resume next
p=inputbox(s,"","")
if p="c" then
exit function
end if
r=split(s,chr(13)+chr(10))
if right(p,1)="#" then
if left(p,len(p)-1)=1 then
msgbox "這是根目錄,不能選擇根目錄!"
GetD s
elseif left(p,len(p)-1)=2 then
GetTheParent =CreateObject("Scripting.FileSystemObject").GetParentFolderName(spath)
msgbox "選擇:" GetTheParent
Document.forms("ValidForm").FPath.Value=GetTheParent
else
d=split(r(left(p,len(p)-1)),".")
msgbox "選擇:" d(1)
Document.forms("ValidForm").FPath.Value=d(1)
spath="Root"
end if
else
if p=1 then
spath="Root"
SFolder
elseif p=2 then
GetTheParent =CreateObject("Scripting.FileSystemObject").GetParentFolderName(spath)
if GetTheParent="" then
spath="Root"
'msgbox "進(jìn)入:根目錄"
else
spath=GetTheParent
'msgbox "進(jìn)入:" GetTheParent
end if
SFolder
else
d=split(r(p),".")
spath=d(1)
'msgbox "進(jìn)入:" d(1)
SFolder
end if
end if
end function
/script>
form id="ValidForm" method="POST" action="--WEBBOT-SELF--">
p>input type="text" name="FPath" size="50" onclick="PastePath">input type="button" value="選擇文件夾" name="SelFolder" onclick="SFolder">/p>
/form>

標(biāo)簽:阜陽(yáng) 武威 梅州 牡丹江 伊春 河南 四平 咸陽(yáng)

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《vbs,hta中選擇文件夾對(duì)話框?qū)崿F(xiàn)代碼》,本文關(guān)鍵詞  vbs,hta,中,選擇,文件夾,對(duì)話框,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《vbs,hta中選擇文件夾對(duì)話框?qū)崿F(xiàn)代碼》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于vbs,hta中選擇文件夾對(duì)話框?qū)崿F(xiàn)代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    贵定县| 莎车县| 吉木乃县| 招远市| 红河县| 新宁县| 邹城市| 商丘市| 竹山县| 福建省| 兰州市| 博罗县| 家居| 安义县| 永济市| 龙川县| 华阴市| 合川市| 海兴县| 竹溪县| 林芝县| 翁牛特旗| 怀柔区| 长春市| 嵊泗县| 龙山县| 龙泉市| 依安县| 嘉义县| 黄大仙区| 泽库县| 水城县| 于都县| 泉州市| 榆社县| 蓬安县| 霍林郭勒市| 新疆| 阿鲁科尔沁旗| 斗六市| 杭锦后旗|