TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
coolcoder
NA
7
0
COMException in VBA Collection
Dec 30 2008 5:58 AM
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.
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
}
Reply
Answers (
0
)
COM Interop problem
Inter-process Communication Between Smart Client Desktop Application and VB5 Desktop Application