使用VBS浏览本地文件的3种方式,获取完整路径(vbs打开网页)干货分享

随心笔谈12个月前发布 admin
89 0


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

© 版权声明

相关文章