Run-time Error - Method 'NameSpace' of IShellDispatch4' failed

A

Alan

I have the following piece of code to return file attribues as per a previous
post

Public Sub getattributes(strFolderpath As String)

Dim arrHeaders(40)

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

Dim rstData As dao.Recordset
Set rstData = CurrentDb.OpenRecordset("tblFiles_Project")
With rstData
For Each strFileName In objFolder.Items
If objFolder.GetDetailsof(strFileName, 2) <> "File Folder" Then
'.Edit
.AddNew
intexepos = InStr(1, strFolderpath, "Exe_Ma") - 1
'MsgBox intexepos
rstData!FilePath = Right(strFolderpath, Len(strFolderpath) - intexepos)
rstData!FileFolder = UCase(Right(strFolderpath, Len(strFolderpath) -
(InStrRev(strFolderpath, "\"))))
rstData!FileName = objFolder.GetDetailsof(strFileName, 0)
rstData!FileType = objFolder.GetDetailsof(strFileName, 2)
rstData!Size = objFolder.GetDetailsof(strFileName, 1)
rstData!DateLastModified = objFolder.GetDetailsof(strFileName, 3)
rstData!Version = objFolder.GetDetailsof(strFileName, 37)
rstData!ProductName = objFolder.GetDetailsof(strFileName, 38)
rstData!ProductVersion = objFolder.GetDetailsof(strFileName, 39)
.Update
End If
Next
End With
End


I am however now getting the error message

Run-time Error '- 2147024894 (80070002)'
Method 'NameSpace' of IShellDispatch4' failed

This code works perfectly in Excel, but not in Access - Has anyone any
pointers or ideas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top