+ Reply to Thread
Results 1 to 14 of 14

Error opening file......"different format than what specified by extension"...

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Error opening file......"different format than what specified by extension"...

    Hi,

    Apparently my program quits after i try to open an excel file. If you open the file manually you get an error upon opening the file...something like this:

    "File you are tyring to open is in a different format than specified by the file extension".

    The problem is i am using an excel macro using VBA and once the file is opened the VBA execution quits.

    The excel file turns out to be an xml file which excel can open the file and have the VBA continue running if i RENAME the file with an "xlsx" extension. The problem is that i cant ask the user to rename the file.........how do i get VBA to open the file without an issue?
    Last edited by welchs101; 05-17-2009 at 08:37 AM.

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Error opening file......"different format than what specified by extension"...

    Why not have the macro rename the file before opening?
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Error opening file......"different format than what specified by extension"...

    hi,

    That is one option i had not thought of but i would rather (if possible) have the macro somehow ignore the error. I have tried "on error resume next" but program execution just stops after file is opened.

  4. #4
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Error opening file......"different format than what specified by extension"...

    Here is a copy of the file that i am having trouble opening. I can open the file but program execution stops just after the file is opened.

    Does anyone know how to open this file using VBA?
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Error opening file......"different format than what specified by extension"...

    Can anyone help?

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Error opening file......"different format than what specified by extension"...

    Mudraker did help. Did you try his suggestion?
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Error opening file......"different format than what specified by extension"...

    hi,

    Renaming file will allow me to read in THIS file but if i rename all files with ".xls" extension to ".xlsx" then i will have a problem other files. Does this make sense? Renaming the file will fix only a specific problem with this file type. The other files with a ".xls" extension which are "correct", if i rename them then i will have a problem.

  8. #8
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Error opening file......"different format than what specified by extension"...

    There is a problem with the excel file i uploaded. I had to remove some personal information and apparently is does not want to open up AT ALL.

    Even changing the extension to ".xlsx" does not seem to work now.

  9. #9
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Error opening file......"different format than what specified by extension"...

    Turns out the file that i am trying to read in........i think its an html file.

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Error opening file......"different format than what specified by extension"...

    Are you opening Excel 2007 files from 2003? If so you need the conversion tool.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  11. #11
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Error opening file......"different format than what specified by extension"...

    the file is created from a web based software. It is automatically saved as an excel file. I dont know if its excel 2007 or 2003 format. I do know its an HTML file type. Excel reads it in ok as long as i change the extension to .html.

    An earlier person suggested i rename the file extension using excel. Does anyone know how to do this in VBA?

    Or if i can somehow select the file to open and then instruct excel its an html file that would work also......i think.

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Error opening file......"different format than what specified by extension"...

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Error opening file......"different format than what specified by extension"...

    thanks shg,

    i appreciate your help.

    for now at least i have a work around and i can open the file.

    Thanks.

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Error opening file......"different format than what specified by extension"...

    You're welcome -- but is was mudraker's idea, I'm just his humble coder ...

    When you get done with the file, you can change it back, of course ...

+ 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