#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Weird error

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

--
Regards,
Tom Ogilvy


" 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Weird error

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird Arithmetic Error Keith Excel Discussion (Misc queries) 7 February 7th 06 06:30 PM
Very weird error Stian Excel Worksheet Functions 4 November 21st 05 10:50 PM
vlookup weird error cutthroatjess Excel Worksheet Functions 3 June 17th 05 01:56 PM
Weird error messages Manuel Excel Discussion (Misc queries) 3 February 17th 05 04:45 PM
Weird error Brad K. Excel Programming 6 January 20th 05 06:48 AM


All times are GMT +1. The time now is 07:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"