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
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
© 版权声明
文章版权归作者所有,未经允许请勿转载。