如何在lotus notes脚本中检索目录地址和文件名

时间:2014-04-16 15:08:07

标签: lotus-notes

我制作了这个莲花笔记脚本,允许我检索计算机的文件夹地址,并将地址重新放入"字段arc_file":

Const MY_COMPUTER = &H11&
Const WINDOW_HANDLE = 0
Const OPTIONS = 0

Const BIF_returnonlyfsdirs   = &H0001
Const BIF_dontgobelowdomain  = &H0002
Const BIF_statustext         = &H0004
Const BIF_returnfsancestors  = &H0008
Const BIF_editbox            = &H0010
Const BIF_validate           = &H0020
Const BIF_browseforcomputer  = &H1000
Const BIF_browseforprinter   = &H2000
Const BIF_browseincludefiles = &H4000

Set uidoc=work.CurrentDocument
If uidoc.EditMode=False Then uidoc.EditMode=True
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path     
Set objFolder = objShell.BrowseForFolder(WINDOW_HANDLE, "Seleziona una cartella:", OPTIONS+ BIF_browseincludefiles , strPath)   
If Not (objFolder Is Nothing) Then
    Set objFolderItem = objFolder.Self
    Call uidoc.FieldSetText("arc_file",Cstr(objFolderItem.Path))
End If

这个脚本为我提前回复: c:\ folder1 \ folder2

但我不知道是否有一种方法可以使用文件名来检索文件的地址, 例如 c:\ folder1 \ folder2 \ image.jpg 当我点击打开特定文件夹的底部时(使用x = Shell(" explorer / root,"&) ; uidoc.FieldGetText(" arc_file"),1))文件已被选中...有人可以帮我吗? 感谢' S

1 个答案:

答案 0 :(得分:2)

最好是使用NotesUIWorkspace中的方法: 获取文件只是:

Dim ws as New NotesUIWorkspace    
Dim varFile as Variant
varFile = ws.OpenFileDialog( False ) 'for one file, for multiple files use True

要使用文件夹:

Dim ws as New NotesUIWorkspace    
Dim varFolder as Variant
varFolder = ws.SaveFileDialog( True ) 'in this case True = directories only

在varFile(0)/ varFolder(0)中是foldername,或isEmpty(varFile)为true,如果没有选择