Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Determining File Types from Extension (Excel 2000 SR-1)

    Hello,

    Is there an easy way to get the full description of the file type from just the three letter extension? I know that windows stores this information, I need to access it in order to present to the user of the spreadsheet.

    Thanks,

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Determining File Types from Extension (Excel 2000 SR-1)

    Feel free to play with the attached.
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Determining File Types from Extension (Excel 2000 SR-1)

    If scripting is allowed on your user's systems, the following code will read the description from the registry:

    Function GetType(Extension As String) As String
    Dim oShell As Object
    Dim strExt As String
    Dim strKey As String

    On Error GoTo ErrHandler

    Set oShell = CreateObject("WScript.Shell")
    strExt = Extension
    If Not (Left(strExt, 1)) = "." Then
    strExt = "." & strExt
    End If
    strKey = oShell.RegRead("HKEY_CLASSES_ROOT" & strExt & "")
    GetType = oShell.RegRead("HKEY_CLASSES_ROOT" & strKey & "")

    ErrHandler:
    Set oShell = Nothing
    End Function

    Examples:
    GetType("doc") or GetType(".doc") will return "Microsoft Word Document"
    GetType("dok") will return a blank string, since .dok is not a registered file type.

    (My code is a shameless ripoff from <post#=279025>post 279025</post#> by <!profile=R2>R2<!/profile>)

  4. #4
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Determining File Types from Extension (Excel 2000 SR-1)

    Thank you for your help. This is exactly what I was looking for.

    Regards,

Posting Permissions

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