+ Reply to Thread
Results 1 to 2 of 2

Calling workbook.saveas depending on excel version

  1. #1
    Ryan
    Guest

    Calling workbook.saveas depending on excel version

    Hi,

    I am working on some software that integrates an excel workbook. I am
    having a problem calling the workbook.saveas method. I am developing on
    XP with excel 2003, but i need this code to work with excel 2000.
    Apparently excel 2000 requires saveas to have 10 arguments while excel
    2003 requires 12 arguments. Ideally I would have something like this:

    if (System.String.Compare(_app.Version,"10") < 0)
    {
    //Office 2000
    _wb.SaveAs(_strFilename, Type.Missing, Type.Missing, Type.Missing,
    Type.Missing, Type.Missing,
    Excel.XlSaveAsAccessMode.xlNoChange,Type.Missing, Type.Missing,
    Type.Missing);
    }
    else
    {
    //Office XP
    _wb.SaveAs(_strFilename, Type.Missing, Type.Missing, Type.Missing,
    Type.Missing, Type.Missing,
    Excel.XlSaveAsAccessMode.xlNoChange,Type.Missing, Type.Missing,
    Type.Missing, Type.Missing,Type.Missing);
    }

    However I cannot compile this on my XP machine because it says "no
    overload for method saveas takes 10 arguments" at the first SaveAs
    call.

    Help!


  2. #2
    NickHK
    Guest

    Re: Calling workbook.saveas depending on excel version

    Ryan,
    Write the code in the oldest version you intend to support.
    Additional arguments in later versions are optional and if missing, take
    their default values.
    If this were not true, there would be no such thing as backwards
    compatibility.

    NickHK

    "Ryan" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I am working on some software that integrates an excel workbook. I am
    > having a problem calling the workbook.saveas method. I am developing on
    > XP with excel 2003, but i need this code to work with excel 2000.
    > Apparently excel 2000 requires saveas to have 10 arguments while excel
    > 2003 requires 12 arguments. Ideally I would have something like this:
    >
    > if (System.String.Compare(_app.Version,"10") < 0)
    > {
    > //Office 2000
    > _wb.SaveAs(_strFilename, Type.Missing, Type.Missing, Type.Missing,
    > Type.Missing, Type.Missing,
    > Excel.XlSaveAsAccessMode.xlNoChange,Type.Missing, Type.Missing,
    > Type.Missing);
    > }
    > else
    > {
    > //Office XP
    > _wb.SaveAs(_strFilename, Type.Missing, Type.Missing, Type.Missing,
    > Type.Missing, Type.Missing,
    > Excel.XlSaveAsAccessMode.xlNoChange,Type.Missing, Type.Missing,
    > Type.Missing, Type.Missing,Type.Missing);
    > }
    >
    > However I cannot compile this on my XP machine because it says "no
    > overload for method saveas takes 10 arguments" at the first SaveAs
    > call.
    >
    > Help!
    >




+ 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