Nello sviluppo delle applicazioni che vanno
a sfogliare il contenuto di una cartella, di sistema, Notes mette a disposizione
solo il metodo OpenFileDialog della classe UIWorkspace che è abbastanza
restrittivo.
Interessante invece è utilizzare questo codice per visualizzare la classica
browser di Windows per tutti coloro che utilizzano notes sotto Windows
( purtoppo sotto Mac è ovvio che ciò non funziona ).
Allego qui sotto il codice:
**********************************************************************
Sub Click(Source As Button)
'-- This script uses the shell.application object's BrowseForFolder.
'-- Properties in shell.application are different from the FSO.
'-- If the folder has files in it, getting the folder path is easy.
'-- If not, the method is circuitous.
'-- there are various options demonstrated in this script. The other script,
'-- BrowseFunction.vbs, contains one funtion to just return the path of
selected item.
Dim ShellApp, FolderObject, ParentFolderObject
Dim strDirectoryPath As String, strParentFolderName As String
Const HOME_DRIVE = "C:"
On Error Goto ErrorHandler
strDirectoryPath = ""
Set ShellApp = CreateObject("Shell.Application")
' The &H4000 part of the line of code below allows for the displaying
of files !
' Set FolderObject = ShellApp.browseforfolder(Clng(0), "Select a file:",
&H4000, HOME_DRIVE )
Set FolderObject = ShellApp.browseforfolder(Clng(0), "Select a directory:",
0, HOME_DRIVE )
'--get title of chosen folder.
strDirectoryPath = FolderObject.Title
'--show msgbox with path of folder selected, if found:
If Instr( strDirectoryPath, ":" ) > 0 Then
strDirectoryPath = HOME_DRIVE
Else
Do
Set ParentFolderObject = FolderObject.ParentFolder
strParentFolderName = ParentFolderObject.Title
If Instr(strParentFolderName, ":") = 0 Then '--it's a
directory
strDirectoryPath = strParentFolderName & "" &
strDirectoryPath
Else '--it's a drive.
extract root folder path (ex.: C: )
strDirectoryPath = HOME_DRIVE & strDirectoryPath
Exit Do
End If
Set FolderObject = ParentFolderObject
Loop Until strParentFolderName = ""
End If ' End of - "If Instr( strDirectoryPath, ":"
) > 0 Then"
Msgbox "Path of chosen folder: " & strDirectoryPath
Set ParentFolderObject = Nothing
Set FolderObject = Nothing
Set ShellApp = Nothing
Exit Sub
ErrorHandler:
Exit Sub
End Sub
*************************************************************************************
Visualizzare OpenFile di Windows al posto della classica Notesiana
- 04/26/2005
- 0 commenti
0 Commenti:
Nessun Commento Trovato