PDA

View Full Version : Using the Shell object



malik641
10-10-2006, 10:36 AM
Hey guys,

I've recently been playing with file manipulation and after some research I found a nice way to organize some mp3s into 2 seperate folders based on the Album title:

Sub MusicFilesMove()
Dim Disc1 As String, Disc2 As String
Dim objShell As Object, objFolder As Object, FileName As Variant

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\Dane Cook\")

Disc1 = objFolder.Items.Item.path & "\Retaliation Disc 1\"
Disc2 = objFolder.Items.Item.path & "\Retaliation Disc 2\"

For Each FileName In objFolder.Items
Select Case objFolder.GetDetailsOf(FileName, 17)
Case "Retaliation (Disc 1)"
Name objFolder.Items.Item.path & "\" & FileName As Disc1 & FileName

Case "Retaliation (Disc 2)"
Name objFolder.Items.Item.path & "\" & FileName As Disc2 & FileName

End Select
Next FileName
End Sub

I was wondering if anyone knows of a good source to learn more about the shell object....it was very difficult for me to get the right path (as shown in bold in my code) because I thought that it would be objFolder.Path rather than objFolder.Items.Item.path

I mean, this serves it's purpose..but I'm much more interested on what else I can do. So I'm looking to find it's methods, properties, collections, etc :)

Thanks

Ivan F Moala
10-10-2006, 07:30 PM
You could have a look here

http://www.xcelfiles.com/Shell32_00.html

malik641
10-11-2006, 10:22 AM
Thanks Ivan I'll check that out :thumb

Marcster
10-11-2006, 11:26 AM
I was wondering if anyone knows of a good source to learn more about the shell object....it was very difficult for me to get the right path (as shown in bold in my code) because I thought that it would be objFolder.Path rather than objFolder.Items.Item.path

I mean, this serves it's purpose..but I'm much more interested on what else I can do. So I'm looking to find it's methods, properties, collections, etc :)

Thanks

Download the Microsoft Windows Script 5.6 documentation:

http://www.microsoft.com/downloads/details.aspx?FamilyID=01592c48-207d-4be1-8a76-1c4099d7bbb9&DisplayLang=en

Provides extensive reference and conceptual documentation.
Aimed at VBScript, JScript but should be easy enough to translate to VBA.

Hope this helps,

Marcster.

malik641
10-11-2006, 12:10 PM
Marcster,

Excellent! Lot of info to read :thumb I like that, especially when it's free :yes

Thanks!

Marcster
10-16-2006, 10:27 AM
Joseph,

If your interested in Windows Scripting, then have a look at what WMI (Windows Management Instrumentation) can access/view/update etc etc:

http://www.microsoft.com/technet/scriptcenter/resources/wmifaq.mspx

Happy viewing... :reading:

Marcster.