Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fso File Object doesn't support Type property

Status
Not open for further replies.

JTBorton

Technical User
Jun 9, 2008
345
DE
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
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.
 
You need a reference set to Microsoft Scripting Runtime for one, and you may also need another one for FileObject, not 100% sure...

Are you sure that's supposed to be FileObject, and not a folder, and the type of folder or file??

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
I think that you'll find that objFile does not hold what you think it holds
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top