+ Reply to Thread
Results 1 to 7 of 7

Weird error

Hybrid View

  1. #1
    Adi
    Guest

    Weird error

    Hi
    I am getting a error saying "?" for the following line:

    Worksheet =(Worksheet)workbook.Worksheets.Add(Type.Missing,
    Type.Missing,Type.Missing, Type.Missing);

    does any one has an explanation to this, i mean how could an error have
    no explaination and just show a "?" on ex.Message (Exception ex)

    Please, help me out.. i don't know what to do!

    Thanks


  2. #2
    paul.robinson@it-tallaght.ie
    Guest

    Re: Weird error

    Hi
    Worksheet and workbook are not good variable names as they are objects
    in Excel VBA. If you want to create a new worksheet in your workbook
    try:

    Set myWorkSheet = myWorkBook.WorkSheets.Add

    where you might have done
    Set myWorkBook = Application.Workbooks("Tester")
    or
    Set myWorkBook = ActiveWorkBook

    look at the parameters in the Add method for control over where it goes
    in the workbook.

    regards
    Paul


  3. #3
    Tom Ogilvy
    Guest

    Re: Weird error

    Your talking about VBA and the OP is talking about .NET.

    --
    Regards,
    Tom Ogilvy


    "paul.robinson@it-tallaght.ie" wrote:

    > Hi
    > Worksheet and workbook are not good variable names as they are objects
    > in Excel VBA. If you want to create a new worksheet in your workbook
    > try:
    >
    > Set myWorkSheet = myWorkBook.WorkSheets.Add
    >
    > where you might have done
    > Set myWorkBook = Application.Workbooks("Tester")
    > or
    > Set myWorkBook = ActiveWorkBook
    >
    > look at the parameters in the Add method for control over where it goes
    > in the workbook.
    >
    > regards
    > Paul
    >
    >


  4. #4
    Adi
    Guest

    Re: Weird error

    hi,
    that was just example line so that it would be easy to understand
    i have thought not used that same names..
    one more thing..
    i am trying to develop excell addin through c#

    now when i try n create a worksheet in active workbook it gives me this
    error in that line which has ex.message as "?" nothing else..
    Mind you this error is not a fixed one, i mean this error is not always
    occuring.. it many times works fine and some times gives the error..(i
    know this is absurd.. but?)


  5. #5
    Adi
    Guest

    Re: Weird error

    hi Tom,
    U r absolutely right!
    And plzz if you know some thing about this help me.. i am stuck
    Thanks


  6. #6
    Tom Ogilvy
    Guest

    Re: Weird error

    I really don't know anything about C# and .NET, but shouldn't it be something
    like:
    Excel.Application oXL;
    Excel._Workbook oWB;
    Excel._Worksheet oSheet

    .. . .

    oSheet = (Excel._Worksheet) oWB.Worksheets.Add(Missing.Value,
    Missing.Value, Missing.Value, Missing.Value);

    Missing.Value instead of Type.Missing

    --
    Regards,
    Tom Ogilvy



    "Adi" wrote:

    > hi Tom,
    > U r absolutely right!
    > And plzz if you know some thing about this help me.. i am stuck
    > Thanks
    >
    >


  7. #7
    Adi
    Guest

    Re: Weird error

    Thanks Tom but as far as I know Missing.Value and Type.Missing gives
    the same result. If there are any differences that you know, please let
    me know too.


+ 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