Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 30th, 2008, 06:13 AM
Registered User
 
Join Date: Oct 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default COMException in VBA Collection

Hi All,

I am converting a Visual Basic 6.0 application to C#.

I need to use VBA Collection object(that is cliect requirements).But sometimes while getting the items from collection object as "

objCollection.Item(ref objclsBOMPresentations)" ,it is giving COMException.So I need to give one if else block to get the type of the item index.

As you can see in the code,that is hardcoded.So I am giving try catch exception to make the control go on.Please suggest me how can I implement IF-Else here.


Code:
                             object rObj ;

                            object objcls1 = "cls1 ";
                            object objcls2 = "cls2";
                            
                            VBA.Collection objCollection = (VBA.Collection)myToolFrame.ActiveObjects;


                            try
                            {
                                rObj = objCollection.Item(ref objcls1);
                                m_windowDistributor_ActivateCurrent(ref rObj);
                            }
                            catch (COMException exception)
                            {
                               //Giving exception here if the item is not cls1 type
                            }

                            try
                            {
                                rObj = objCollection.Item(ref objcls2);
                                m_windowDistributor_ActivateCurrent(ref rObj);
                            }
                            catch(COMException exception)
                            {
                                
                             //Giving exception here if the item is not cls2 type                          

                          }





Similar Threads
Thread Thread Starter Forum Replies Last Post
COMException Catastrophic Failure jdmc C# 4 December 16th, 2009 10:30 AM
System.Runtime.InteropServices.COMException (0x800 mithunak C# 0 February 16th, 2006 02:56 AM
System.RunTime.InteropServices.ComException mohitbhutani C# 0 October 17th, 2005 02:57 AM
System.Runtime.InteropServices.COMException: Catas azeemfraz VS.NET 2002/2003 0 February 17th, 2004 08:58 AM
'System.Runtime.InteropServices.COMException' occu karthey Forum and Wrox.com Feedback 1 August 11th, 2003 10:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.