In this thread http://ozgrid.com/forum/viewthread.php?tid=1783 AJW references the VBS for copying files.
:info: Thanks AJW, you have prompted me to TRY and finish one of my Site pages on this DLL....
What AJW has really found is the power of the Windows Core DLLs,
specifically the Shell32.Dll of which one of it's primary responsibilities is
managing and providing access to the wide variety of objects that make up the system
eg. Network printers, Other networked computers, Control Panel applications, The Recycle Bin etc.
The Shell object represents the objects in the Windows Shell.
You can use the methods exposed by the Shell object to:
Open, explore, and browse for folders.(See below)
Minimize, restore, cascade, or tile open windows.
Launch Control Panel applications.
Display system dialog boxes (The copy routine)
This DLL is referenced in AJW's code via this statement;
Set objShell = CreateObject("Shell.Application")
:exclamat:The code doesn't need to be executed via VBS, VBA or any Scripting language that
supports COM will do the job. eg Java
Also the Native VBA code will do it.
Most of the programming elements in the Shell and common controls are contained in three DLLs;
Comctl32.dll
Shell32.dll
and Shlwapi.dll. (Shell light weight API)
You should be mindful of the Shell version because of ongoing enhancements, different versions
of these DLLs implement different features.
Version DLL Distribution Platform
4.0 All Microsoft® Windows® 95/Microsoft Windows NT® 4.0.
4.7 All Microsoft Internet Explorer 3.x.
4.71 All Internet Explorer 4.0.
4.72 All Internet Explorer 4.01 and Windows 98.
5.0 Shlwapi.dll Internet Explorer 5.
6.0 Shlwapi.dll Internet Explorer 6 and Windows XP.
5.0 Shell32.dll Windows 2000 and Windows Millennium Edition (Windows Me).
6.0 Shell32.dll Windows XP.
5.8 Comctl32.dll Internet Explorer 5.
5.81 Comctl32.dll Windows 2000 and Windows Me.
6.0 Comctl32.dll Windows XP.
I am currently doing a write up on these powerful core DLLs of which the Shell32.Dll is one.
[One Example here for Now ]
http://www.xcelfiles.com/Shell32_01.html
Here is just a few examples of what you CAN DO, I'll leave the detailed explaination @ my site when finished.
Option Explicit
'// Requires DLL version shell32.dll version 4.71 or later
'// Operating systems
'// Win2000, WinNT 4.0 with Internet Explorer*4.0, Win98, Win95 with Internet Explorer*4.0
'Item Identifiers and Identifier Lists
'The Shell uses object identifiers within the Shell's namespace.
'All objects visible in the Shell (files, directories, servers, workgroups, and so on)
'have unique identifiers among the objects within their parent folder.
'These identifiers are called item identifiers, and they have the SHITEMID data type
'as defined in the Shtypes.h header file. An item identifier is a variable-length byte
'stream that contains information that identifies an object within a folder.
'Only the creator of an item identifier knows the content and format of the identifier.
'The only part of an item identifier that the Shell uses is the first two bytes,
'which specify the size of the identifier.
'Each parent folder has its own item identifier that identifies it within its own parent folder.
'Thus, any Shell object can be uniquely identified by a list of item identifiers.
'A parent folder keeps a list of identifiers for the items it contains.
'The list has the ITEMIDLIST data type. Item identifier lists are allocated by the Shell
'and may be passed across Shell interfaces, such as IShellFolder. It is important to remember
'that each identifier in an item identifier list is only meaningful within the context of its parent folder.
'An application can set a shortcut's item identifier list by using the SetIDList method.
'This method is useful when setting a shortcut to an object that is not a file, such as
'a printer or disk drive. An application can retrieve a shortcut's item identifier list
'by using the GetIDList method.
'What is a PIDL? Why not just use file system paths?
'A PIDL (Program ID list) is a way of identifying any namespace object.
'You can also use paths to identify namespace objects, but only if they are part of
'the file system. With namespace objects that are not part of the file system, you must use PIDLs.
Private Const BIF_BROWSEFORCOMPUTER = &H1000
Private Const BIF_BROWSEFORPRINTER = &H2000
Private Const BIF_BROWSEINCLUDEFILES = &H4000
Private Const BIF_BROWSEINCLUDEURLS = &H80
Private Const BIF_DONTGOBELOWDOMAIN = &H2
Private Const BIF_EDITBOX = &H10
Private Const BIF_NEWDIALOGSTYLE = &H40
Private Const BIF_RETURNFSANCESTORS = &H8
Private Const BIF_RETURNONLYFSDIRS = &H1
Private Const BIF_SHAREABLE = &H8000
Private Const BIF_STATUSTEXT = &H4
Private Const BIF_USENEWUI = &H40
Private Const BIF_VALIDATE = &H20
Sub BrowseForFolderShell()
'//Minimum DLL version shell32.dll version 4.71 or later
'//Minimum operating systems Windows*2000, Windows NT 4.0 with Internet Explorer*4.0,
'//Windows*98, Windows 95 with Internet Explorer*4.0
Dim objShell As Object
Dim objFolder As Object
Dim strFolderFullPath As String
Set objShell = CreateObject("Shell.Application")
'oFolder = Shell.BrowseForFolder(Hwnd, sTitle, iOptions [, vRootFolder])
Set objFolder = objShell.BrowseForFolder(0, "Please select a folder", BIF_NEWDIALOGSTYLE Or BIF_USENEWUI, SpecFolders.CSIDL_PERSONAL) 'SpecFolders.CSIDL_FAVORITES
If (Not objFolder Is Nothing) Then
'// NB: If SpecFolder= 0 = Desktop then ....
On Error Resume Next
If IsError(objFolder.Items.Item.path) Then strFolderFullPath = CStr(objFolder): GoTo GotIt
On Error GoTo 0
'// Is it the Root Dir?...if so change
If Len(objFolder.Items.Item.path) > 3 Then
strFolderFullPath = objFolder.Items.Item.path & Application.PathSeparator
Else
strFolderFullPath = objFolder.Items.Item.path
End If
Else
MsgBox "User cancelled": GoTo Xit
End If
GotIt:
MsgBox "You selected:= " & strFolderFullPath, vbInformation, "ObjectFolder:= " & objFolder
Xit:
Set objFolder = Nothing
Set objShell = Nothing
End Sub
Display More