如何创建一个对话框来输入文件路径

时间:2015-04-20 09:17:07

标签: vbscript

Set fso = CreateObject("Scripting.FileSystemObject")
Set objFolder = fso.GetFolder("C:\New folder _1")

我正在使用此代码来读取文件夹路径。 objFolder将存储文件夹的路径。 以同样的方式,当我运行总代码时,我需要一个对话框在哪里 我应该能够进入文件夹路径。

1 个答案:

答案 0 :(得分:0)

Browse4File的这个脚本:browse files in folder

和Browse4Folder的代码:

Option Explicit
Dim RootFolder
RootFolder = Browse4Folder
MsgBox RootFolder,VbInformation,RootFolder
'**********************************************************************************************
Function Browse4Folder()
    Dim objShell,objFolder,Message
    Message = "Please select a folder in order to scan into it and its subfolders"
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.BrowseForFolder(0,Message,1,"c:\Programs")
    If objFolder Is Nothing Then
        Wscript.Quit
    End If
    Browse4Folder = objFolder.self.path
end Function
'**********************************************************************************************