在特定目录中打开目录选择器对话框

时间:2013-05-27 07:04:07

标签: winapi vba lotusscript

我有以下代码来显示目录选择器对话框

Function selectOutputFolder(lastPath As String) As String
    Const BIF_NEWDIALOGSTYLE = &H00000040
    Dim objShell As Variant
    Dim objFolder As Variant
    Dim objFolderItem As Variant
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.BrowseForFolder(0, "Choose a directory", BIF_NEWDIALOGSTYLE, lastPath)
    If Not (objFolder Is Nothing) Then
        Set objFolderItem = objFolder.Self
        selectOutputFolder = objFolderItem.Path 
    End If
End Function

我正在使用BrowseForFolder的第4个参数,这只是目录遍历的限制,而不是在打开时跳转到此文件夹。

这是在Lotus脚本代理中实现的,所以如果你知道vba或lotusscript中的任何替代方法,请告诉我!

1 个答案:

答案 0 :(得分:3)

通过使用NotesUIWorkspace-Class的SaveFileDialog-方法,可以在LotusScript中执行“标准”方法。

'...your sub goes around this
Dim ws as New NotesUIWorkspace
Dim varPaths as Variant
varPaths = ws.SaveFileDialog(  True  , "Choose file" , "" , lastPath )
If not isEmpty( varPaths ) then
  selectOutputFolder = varPaths(0)
End If