Shell function

2 posts / 0 new
Last post
tryvltkcb
Offline
Joined: 10/25/2018 - 02:49
Shell function

Hi all,
I have read some scripts writing about import multiple files and there is a part about Shell function that I am not clear. For example
 
Function BrowseFolder()
Dim oFolder, oFolderItem
Dim oPath, oShell, strPath
Dim msg As String
Set oShell = CreateObject( "Shell.Application" )
Set oFolder = oShell.Namespace(17)
Set oFolderItem = oFolder.Self
strPath = oFolderItem.Path
msg = "Please select your working directory where"
msg = msg &  Chr(10) &  "the excel files are located:" 
Set oFolder = oShell.BrowseForFolder(0, msg, 1, strPath )
If oFolder Is Nothing Then
BrowseFolder = ""
Exit Function
End If
Set oFolderItem = oFolder.Self
oPath = oFolderItem.Path
BrowseFolder = oPath
End Function
 
What does "Shell.Application" mean and these bold lines mean (its purpose)? As far as I know, Shell used to call an application (e.g Sheel "notepad" to open a notepad file) but Shell.Application is quite weird for me. 
 
Thanks & appriciate your response.
 

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Per the microsoft documentation the shell command does:

One of the primary responsibilities of the Shell is managing and providing access to the wide variety of objects that make up the system. The most numerous and familiar of these objects are the folders and files that reside on computer disk drives. (https://docs.microsoft.com/en-us/windows/desktop/shell/namespace-intro)

This particular shell command allows you access to selecting a folder,  you can find detailed documentation on the shell object here: https://msdn.microsoft.com/en-us/library/windows/desktop/bb774094(v=vs.85).aspx