让用户选择放置创建的文本文件的目录

Let user pick directory of where a created text file is placed

如何获取用户输入并将其作为文本文件的目录?

我尝试在 ("Inp.txt") 周围加上引号,但这并没有读取实际的用户输入。

Set oFSO = CreateObject("Scripting.FileSystemObject")
Inp= InputBox("Please Enter Desired Location of Log File:")
If Inp= "" Then  
    Set oTF = oFSO.CreateTextFile("C:\Old Files.txt")
Else 
    Set oTF = oFSO.CreateTextFile(Inp.txt)
End If 

我想提示用户进行输入,询问他们希望将创建的文本文件放在哪里;如果留空,我会将其设置为默认位置。我尝试设置输入框提示,但当我将其用作文本文件位置时,我收到 "Object Required" 运行时错误。

Build 目录和文件名的完整路径:

Set oTF = oFSO.CreateTextFile(oFSO.BuildPath(Inp, "output.txt"))

不过,我建议让用户 browse 使用该文件夹。

Set app = CreateObject( "Shell.Application" )
Set d = app.BrowseForFolder(0, "Select Folder", 1, "C:\")
If d Is Nothing Then
    Inp = "C:\"
Else
    Inp = d.Self.Path
End If

Set oTF = oFSO.CreateTextFile(oFSO.BuildPath(Inp, "output.txt"))