+ Reply to Thread
Results 1 to 8 of 8

SaveAS Filename compatibility problem

  1. #1
    Registered User
    Join Date
    06-03-2010
    Location
    Hertfordshire, England
    MS-Off Ver
    Excel 2010
    Posts
    51

    SaveAS Filename compatibility problem

    I have a macro/VBA code that I've developed in Office 2010 Excel which is working ok, just need to sort out some cosmetics.

    However I need it to run on earlier versions of Excel (back to Office 97 or Excel 2002), and when I test it on a 2002 version of Excel (on another PC) it's giving Compile errors. The particular one I'm struggling with is in:

    Please Login or Register  to view this content.
    where the FileFormat:=xlExcel8 throws up a compile error. There are few SaveAs statements throughout the macro.

    The TempDataPathFile variable is "d:\Data\Test\Temp Data.xls" and the PC I'm developing on has Excel set to save in compatibility mode by default, and the file containing the macro is a .xls file.

    How can I modify the code so that it will compile and run on different versions of Excel?

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: SaveAS Filename compatibility problem

    I am not sure about 97 version (have handy 2000), but you can try xlExcel7 instead of xlExcel8. Anyway it is probably quite simple workbook - isn't it?
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    06-03-2010
    Location
    Hertfordshire, England
    MS-Off Ver
    Excel 2010
    Posts
    51

    Re: SaveAS Filename compatibility problem

    Quote Originally Posted by Kaper View Post
    Anyway it is probably quite simple workbook - isn't it?
    Maybe by your standards it is but the 425 lines of it has so far taken me around 35 hours to get working, and still not finished. Very much a newbie with macros and VBA.

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: SaveAS Filename compatibility problem

    I don't comment on the code complexity ;-)

    It was only about the generated file - does it have complex structure and advanced (again not computation complexity but introduced with relatively new versions of excel) formula and formatting inside?
    If the file is rather simple I suggested you can save it in even older format - like excel 7 (excel95).

    To let code "recognize" what excel it is running on, you could use Application.Version

    Have a look on such piece (having in mind that xlExcel8 is not recognized in older versions its numerical equivaklent 56 can be used) which saves in excel pre-2007 as standard format and starting 2007 (version 12) as xls:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-03-2010
    Location
    Hertfordshire, England
    MS-Off Ver
    Excel 2010
    Posts
    51

    Re: SaveAS Filename compatibility problem

    Ah, I misunderstood, sorry!

    The generated file is VERY simple, just 5 columns of text and integers, no formatting and no formula. It's just being used as a temporary file to assemble the data which will be then copied to a couple of .csv files for importing as Gmail contact lists.

    I didn't know about the iif function either, that might come in handy

    Thanks, will post back after testing.

  6. #6
    Registered User
    Join Date
    06-03-2010
    Location
    Hertfordshire, England
    MS-Off Ver
    Excel 2010
    Posts
    51

    Re: SaveAS Filename compatibility problem

    The code above:

    Please Login or Register  to view this content.
    Runs ok in Excel (Office 2010) but in Excel 2003 fails with a compile error - Sub or Function not defined, with the iff highlighted. Looks like it's not supported in earlier versions.

  7. #7
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: SaveAS Filename compatibility problem

    ??? tested on Excel 2000. Works - may be iff is a problem? it is iif.
    Test setup:
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-03-2010
    Location
    Hertfordshire, England
    MS-Off Ver
    Excel 2010
    Posts
    51

    Re: SaveAS Filename compatibility problem

    I think I need a new eye test, or learned to read more carefully

    iif does indeed work, although I did replace the "xlWorkbookNormalwith" -4143 after reading this:

    http://www.rondebruin.nl/win/s5/win001.htm

    Thanks Kaper

+ 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. Use VBA to change a filename while using SaveAs
    By BigBas in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-14-2007, 01:55 AM
  2. VBA- SaveAs filename and add
    By Lucifix in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-21-2007, 06:09 AM
  3. [SOLVED] SaveAs using two cells for filename
    By David in forum Excel General
    Replies: 5
    Last Post: 06-04-2005, 07:05 AM
  4. FileName SaveAs
    By alanford in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2005, 10:48 AM
  5. 'ActiveWorkbook.SaveAs Filename'
    By TOMB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-15-2005, 08:07 PM

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