I'm trying to use an fso file object in microsoft excel 2010 to access and manipulate a file. However when I try to access the Type property excel tells me that the object doesn't support this property or method. All of the other properties of the file object work fine, such as Name, Size, Path, etc... Has anyone ran into this issue before and does anyone have an idea for a fix?
Calling Code
FileSystemObject Class Module
fsoFileObject Class module
-Joshua
If it's not broken, it doesn't have enough parts yet.
Calling Code
Code:
Dim FSO As FileSystemObject
Dim fsoFile As fsoFileObject
Dim wkbSearch2Excel As Workbook
Set FSO = New FileSystemObject
Set fsoFile = New fsoFileObject
fsoFile.SetFile FSO.GetFile(Application.PickFile(Title:="Select the Excel worksheet that was downloaded from the Edesk UE Search2Excel function."))
Debug.Print fsoFile.FileType
FileSystemObject Class Module
Code:
Public Function GetFile(ByVal FileSpec As String) As fsoFileObject
Dim objCatch As Object
'On Error Resume Next
Set GetFile = New fsoFileObject
Set objCatch = objFSO.GetFile(FileSpec)
If Err.Number = 76 Or objCatch Is Nothing Then
Set GetFile = Nothing
MsgBox "The path, " & Chr(34) & FileSpec & Chr(34) & ", was not found, or you do not have permission to access to this file."
Else
GetFile.SetFile objCatch
End If
On Error GoTo 0
End Function
fsoFileObject Class module
Code:
Private objFile As Object
Public Sub SetFile(FileObject As Object)
Set objFile = FileObject
End Sub
Public Property Get FileType() As String
[highlight #FCE94F]FileType = objFile.Type[/highlight]
End Property
Public Property Get Path() As String
Path = objFile.Path
End Property
Public Property Get ShortPath() As String
ShortPath = objFile.ShortPath
End Property
Public Property Get Size() As Double
Size = objFile.Size
End Property
-Joshua
If it's not broken, it doesn't have enough parts yet.