+ Reply to Thread
Results 1 to 2 of 2

Check file format before opening Excel file

  1. #1
    Registered User
    Join Date
    12-26-2014
    Location
    Temuco, Chile
    MS-Off Ver
    2010
    Posts
    1

    Check file format before opening Excel file

    Hi there, guys... I'm running a macro to loop through Excel files in a folder, open them, explore data to extract available info, and finally create a PDF from explored workbook.

    The code deals with corrupt files by repairing, or otherwise, skipping them ("On Error Goto" Statement). Still, there's a problem with format / extension error message prompting (see image below), even though DisplayAlerts and EnableEvents are set to False.

    I've checked for FileFormat from file (by opening with CorrupLoad:=xlExtractData argument) and it returns 56, meaning it's an xlExcel8 file (97-2003 format in Excel 2007-2013, xls).

    Warning.png


    Is there any VBA code to skip this file(s) before opening, if they are to prompt this message.


    Thanks in advance!

  2. #2
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Check file format before opening Excel file

    Can't you just recognize them by the extension of the file and skip them?

    Case "xls": FileFormatValue = 56
    Case "xlsx": FileFormatValue = 51
    Case "xlsm": FileFormatValue = 52
    Case "xlsb": FileFormatValue = 50

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Error:Invalid File format,while opening an Excel Template file
    By Saurabh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-02-2022, 06:50 AM
  2. check if file exists and opening it based on file date
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-26-2014, 03:45 AM
  3. Replies: 6
    Last Post: 05-01-2013, 05:33 PM
  4. File format is not valid - opening word file by vba
    By matsuchika in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2013, 01:36 PM
  5. Replies: 1
    Last Post: 12-07-2005, 01:55 PM
  6. opening csv file in regular excel format
    By sureshbabussb in forum Excel General
    Replies: 1
    Last Post: 12-06-2005, 12:00 PM
  7. Replies: 1
    Last Post: 10-13-2005, 01:05 AM

Tags for this Thread

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