Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 419
Default CreateObject - Namespace variable

Alan,

I think the problem is that you are not assigning a value to your
strFolderPath variable before the "Set objFolder =
objShell.Namespace(strFolderPath)" line of code.

I would also declare your variable.

Maybe something like this:

Public Sub getattributes(strFolderPath As String)

Dim arrHeaders(40)
Dim strFolderPath As String


strFolderPath = "C:\My Documents"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(strFolderPath)

For i = 0 To 39
arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
Range("A1").Select
ActiveCell.Offset(0, i) = arrHeaders(i)
Next

ActiveCell(2, 1).Select

For Each strFileName In objFolder.Items
For i = 0 To 39
ActiveCell.Offset(0, i) =
objFolder.GetDetailsOf(strFileName, i)
Next
ActiveCell.Offset(1, 0).Select
Next

End Sub

HTH,

Conan Kelly


"Alan" wrote in message
...
I think i have managed to cobble a bit of code together that will allow me
to
get all file attributes from all files with a folder... however I would
seek
to call this routine for every folde in a directory and as a result I am
seeking to use a string variable for the objShell.Namespace declaration...
However I get errors
Run time error 91 ... Object Variable or withblock variable unset

If I enter a single directory string in place of the variable "C:\My
Documents" it works fine ??
My Code is

Public Sub getattributes(strFolderPath As String)

Dim arrHeaders(40)

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(strFolderPath)

For i = 0 To 39
arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
Range("A1").Select
ActiveCell.Offset(0, i) = arrHeaders(i)
Next
ActiveCell(2, 1).Select
For Each strFileName In objFolder.Items
For i = 0 To 39
ActiveCell.Offset(0, i) = objFolder.GetDetailsOf(strFileName, i)
Next
ActiveCell.Offset(1, 0).Select
Next

End Sub

Any help with this variable or a way round this would be appreciated

Regards



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem using obj.Namespace(sourceFileName) Namespace(DestinationFilename).Itemsand then opening the xls file which creates a Temp Folder inside Temp Yuvraj Excel Discussion (Misc queries) 3 May 3rd 09 11:59 AM
Excel does not recognize xsd:import namespace??? martinitram Excel Programming 0 June 23rd 06 03:56 PM
namespace.pickfolder Steve[_63_] Excel Programming 2 September 1st 05 12:39 PM
Smart Documents - XSD and Namespace Paul Hasell Excel Programming 7 August 31st 05 06:07 PM
Macro looking to Outlook for namespace. gobjob Excel Programming 1 July 26th 05 11:58 PM


All times are GMT +1. The time now is 01:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"