Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Oct 2007
    Posts
    172
    Thanks
    0
    Thanked 2 Times in 1 Post

    FileSystemObject and File.Type property Text Document problem

    Hi all,

    I've written a macro which uses the FileSystemObject and the File Object. Specifically I am checking the File.Type property to see if the file is a text document. According to http://msdn.microsoft.com/en-us/libr...(v=vs.60).aspx this property should have the value "Text Document" if the file is a text file (*.txt).

    This works in 99% of cases, but I have a curious case within my company where on 2 people's machines, the property has the value "TXT File" rather than "Text Document". The files on everyone's machines are the same (copies distributed automatically via a network login script), the code is the same etc., the OS is the same (Windows 7 Pro), so I'm struggling to think of what could be different on these two machines!

    Any help appreciated!

    Dominic

  2. #2
    2 Star Lounger
    Join Date
    Oct 2007
    Posts
    172
    Thanks
    0
    Thanked 2 Times in 1 Post
    ok I'm beginning to think it has something to do with the file associations with installed applications. So if an installed application is associated to a file type, then the file information returned by the FSO will come from the installed application.

    I should explicitly check the file extension rather than relying on the file.type information!

  3. #3
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    You can get the file extension using something along the lines of...
    fsoSysObj.GetExtensionName(strFilePath)
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •