+ Reply to Thread
Results 1 to 6 of 6

Determine if a file IS a workbook before opening

  1. #1
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Question Determine if a file IS a workbook before opening

    Is there anyway I can test / inspect a file before attempting to open it to check that it is indeed an Excel workbook?

    I don't want to do it by file extension as that can / will be changed, but rather wondered if there was anyway to examine the ACTUAL file?
    I'm wondering if all Excel workbook files start with a particular section of data or anything?

    Thanks
    Last edited by Phil_V; 08-06-2009 at 09:37 AM.
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Determine if a file IS a workbook before opening

    This seems to work for most types except .xlb files:
    Please Login or Register  to view this content.
    but I haven't tested against 2007 file types.
    Remember what the dormouse said
    Feed your head

  3. #3
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264

    Re: Determine if a file IS a workbook before opening

    Quote Originally Posted by romperstomper View Post
    This seems to work for most types except .xlb files:
    A pedant you may be - but at least you're a useful one That's pretty cool.
    Richard Schollar
    Microsoft MVP - Excel

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Determine if a file IS a workbook before opening

    Why thank you, kind sir.

    I should add that I don't know if that is format specific - i.e. whether it will work with all the BIFF versions.
    Last edited by romperstomper; 08-06-2009 at 08:56 AM.

  5. #5
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Determine if a file IS a workbook before opening

    Brilliant

    I'll bear in mind that it probably won't work against the new format for Xl2007, but thats not an issue for me, so thanks

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Determine if a file IS a workbook before opening

    I'd do some testing first, before you use it in anger, since I only just wrote it and haven't exactly stress-tested it!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1