激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

香港云服务器
服務器之家 - 腳本之家 - VBS - 使用VBS瀏覽本地文件的3種方式,獲取完整路徑

使用VBS瀏覽本地文件的3種方式,獲取完整路徑

2020-08-20 10:48VBS教程網 VBS

這篇文章主要介紹了使用VBS瀏覽本地文件的3種方式,獲取完整路徑,需要的朋友可以參考下

因為系統組件差異,所以代碼也有不同文章最后服務器之家給出一個通用的代碼

XP下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Function BrowseForFile( )
' Select File dialog based on a script by Mayayana
' Known issues:
' * Tree view always opens Desktop folder
' * In Win7/IE8 only the file NAME is returned correctly, the path returned will always be C:\fakepath\
' * If a shortcut to a file is selected, the name of that FILE will be returned, not the shortcut's
'On Error Resume Next 
'===========1, file browserer in XP ==================
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "txt|*.txt"
objDialog.InitialDir = "C:\"
intResult = objDialog.ShowOpen
If intResult <> 0 Then
    BrowseForFile = objDialog.FileName
    exit function
else
    msgbox "Error."
End If
end function
BrowseForFile

2003下'for windows 2003

?
1
2
3
4
5
Function SelectAFile
Set objDialog = CreateObject("SAFRCFileDlg.FileOpen")
intResult = objDialog.OpenFileOpenDlg
SelectAFile = objDialog.FileName
End Function

瀏覽器方式:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Function BrowseForFile( )
 '===========2, fileselect in IE ======================
 'Another way to get file path
  Dim objIE, strSelected
  BrowseForFile = ""
  Set objIE = CreateObject( "InternetExplorer.Application" )
objIE.ToolBar = False
objIE.Resizable = False
objIE.StatusBar = False
objIE.Width = 300
objIE.Height = 100
  objIE.visible = True
  objIE.Navigate( "about:blank" )
  Do Until objIE.ReadyState = 4
  Loop
 ' Center the dialog window on the screen
 With objIE.Document.ParentWindow.Screen
 objIE.Left = (.AvailWidth - objIE.Width ) \ 4
 objIE.Top = (.Availheight - objIE.Height) \ 4
 End With
  objIE.Document.Write "<HTML><BODY><INPUT ID=""FileSelect"" NAME=""FileSelect"" TYPE=""file""><BODY></HTML>"
  With objIE.Document.all.FileSelect
    .focus
    .click
    strSelected = .value
  End With
  objIE.Quit
  Set objIE = Nothing
 If Trim(strSelected) = "" Then
 Msgbox "You selected no file."
 Wscript.Quit
 End If
 BrowseForFile = strSelected
End Function
 
BrowseForFile

有沒有發現上面的代碼運行不易啊,這里服務器之家小編為大家分享一個可用的,雖然上面的的代碼不能用但學習參考一下還是不錯的,現在因為平臺愿意導致,原來這些代碼都是可以使用的。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Function ChooseFile()
   Dim Result
   Result = ""
   Dim IE : Set IE = CreateObject("InternetExplorer.Application")
   With IE
     .Visible = False
     .Navigate("about:blank")
     Do Until .ReadyState = 4 : Loop
     With .Document
       .Write "<html><body><input id='f' type='file'></body></html>"
       With .All.f
         .Focus
         .Click
         Result = .Value
       End With
     End With
     .Quit
   End With
   Set IE = Nothing
  ChooseFile = Result
End Function
ChooseFile

好了這篇 關于vbs選擇本地文件功能的代碼就介紹到這了,需要的朋友可以參考一下。

延伸 · 閱讀

精彩推薦
463
主站蜘蛛池模板: 成人午夜视频免费看 | 久久久久二区 | 自拍偷拍亚洲图片 | 一级做受毛片免费大片 | 中国a级黄色片 | 久久国精品 | 国产porn在线| 成人在线视频免费看 | 萌白酱福利视频在线网站 | 欧美一级黄色网 | 亚洲白嫩在线观看 | 亚洲av毛片在线观看 | 久久久久国产一区二区三区不卡 | 色妞色视频一区二区三区四区 | 高清视频91 | 快播av在线 | 国产资源在线视频 | 看中国一级毛片 | 韩国三级日本三级香港三级黄 | 久久精品视频一区 | 色网站免费观看 | 亚洲3atv精品一区二区三区 | 国产一级毛片a | 性aaa| 日韩av电影在线免费观看 | 中国嫩模一级毛片 | 91免费视频版| hdbbwsexvideo| 88xx成人永久免费观看 | 中文字幕四区 | 午夜视频观看 | 亚洲免费片 | 国产毛片网 | 日韩激情| 色交视频 | 国产一级在线看 | 毛片视频免费观看 | 99爱视频在线观看 | 国产美女一区二区在线观看 | 爱福利视频网 | 色就色 综合偷拍区91网 |