大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
VBS中怎么浏览本地文件,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
你所需要的网站建设服务,我们均能行业靠前的水平为你提供.标准是产品质量的保证,主要从事网站制作、成都网站建设、企业网站建设、手机网站开发、网页设计、高端网站设计、网页制作、做网站、建网站。成都创新互联公司拥有实力坚强的技术研发团队及素养的视觉设计专才。因为系统组件差异,所以代码也有不同文章最后我们给出一个通用的代码
XP下:
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.ShowOpenIf intResult <> 0 ThenBrowseForFile = objDialog.FileNameexit functionelsemsgbox "Error."End Ifend functionBrowseForFile
2003下'for windows 2003
Function SelectAFileSet objDialog = CreateObject("SAFRCFileDlg.FileOpen")intResult = objDialog.OpenFileOpenDlgSelectAFile = objDialog.FileNameEnd Function
浏览器方式:
Function BrowseForFile( ) '===========2, fileselect in IE ====================== 'Another way to get file path Dim objIE, strSelected BrowseForFile = "" Set objIE = CreateObject( "InternetExplorer.Application" )objIE.ToolBar = FalseobjIE.Resizable = FalseobjIE.StatusBar = False objIE.Width = 300objIE.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 "
" 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 = strSelectedEnd FunctionBrowseForFile有没有发现上面的代码运行不易啊,这里我们小编为大家分享一个可用的,虽然上面的的代码不能用但学习参考一下还是不错的,现在因为平台愿意导致,原来这些代码都是可以使用的。
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 "
" With .All.f .Focus .Click Result = .Value End With End With .Quit End With Set IE = Nothing ChooseFile = ResultEnd FunctionChooseFile看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注创新互联行业资讯频道,感谢您对创新互联网站建设公司,的支持。