VBS SELECT folder Effect Code _vbs

Source: Internet
Author: User
There are two ways to do this without components:

Set objfile = CreateObject ("Safrcfiledlg.fileopen")
Set Objshell = CreateObject ("Shell.Application")

There are examples in this blog.

If you call the VB component, you can:

Flag = &h200
Whichone = OpenFile ("Choose a file!", "C:\", "everything|*.*| textfiles|*. Txt| word-documents|*. DOC ", 2, Flag)
MsgBox "Raw data returned:" & Whichone
' Split up multi selection Result:
' is used as separator:
Whichone = Split (Whichone, "")
' field index 0 contains path information:
Path = Whichone (0)
' List all the files:
' How many files were selected?
FileCount = UBound (Whichone)
If Filecount=0 Then
' Just one file selected!
MsgBox "You selected one file:" & Whichone (0)
' Check status ' Read only checkbox
' is bit 1 set or cleared?
' works only if just one file is selected!
MsgBox "returned flag:" & Flag
if (flag and 1) then
' (flag and 1) <>0, transforms to True
' Bit is set!
MsgBox "ReadOnly selected!"
Else
MsgBox "ReadOnly not selected!"
End If
' Check whether selected file is of default type (TXT)
if (flag and 1024) then
MsgBox "selected file is no txt file!"
Else
MsgBox "Selected file is of default type!"
End If
Else
' More than one file selected!
MsgBox "you selected" & FileCount & "Files!"
For x = 1 to UBound (Whichone)
List = list & path & Whichone (x) & vbcr
Next
MsgBox List
End If

function OpenFile (title, dir, filter, index, flags)
Set Comdlg = CreateObject ("Mscomdlg.commondialog")
Comdlg.filter = Filter
Comdlg. FilterIndex = Index
Comdlg. Flags = Flags
Comdlg. MaxFileSize = 260
Comdlg. CancelError = False
Comdlg. DialogTitle = Title
Comdlg. Initdir = Dir
' Set txt as default
Comdlg. Defaultext = "txt"
Comdlg. ShowOpen
OpenFile = Comdlg.filename
' Important:return flag Status so your main script can
' Check it:
Flags = Comdlg. Flags
End Function

Component Related file Download Http://xiazai.jb51.net/jbtools/vb6controls.rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.