Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Can't pass VBComponent to Sub Procedure in VB.Net

I posted this a few days back and for some reason cannot find this in the
Microsift Office Newsgroups. Yet when I google it shows up he

http://www.pcreview.co.uk/forums/thread-3908301.php

Anways here it is again:

I am getting an error in VB.Net when trying to do the following:

Dim VBComp As Microsoft.Vbe.Interop.VBComponent
For Each VBComp In xlBook.VBProject.VBComponents
DoSomething (VBComp)
Next

Sub DoSomething(ByVal X As Microsoft.Vbe.Interop.Component)
'Do something
End Sub

If fails on the line: DoSomething (VBComp)

and says:

System.InvalidCastException was unhandled
Message="Unable to cast COM object of type 'System.__ComObject' to
interface type 'Microsoft.Vbe.Interop.Component'. This operation failed
because the QueryInterface call on the COM component for the interface with
IID '{0002E163-0000-0000-C000-000000000046}' failed due to the following
error: No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE))."

There was a response which suggested going to the following link as it
highlights that seems that I may need the explicit cast:

http://social.msdn.microsoft.com/For...b-3eea65796dd2

But I cannot get this to work either. It uses the following sytax:
Friend Sub copyComponents(ByVal src As
Microsoft.Office.Interop.Excel.Workbook)

Dim srcVBP As VBIDE.VBProject = src.VBProject
For Each vbaComp As VBIDE.VBComponent In srcVBP.VBComponents

Next

I cannot type in VBIDE.VBProject as a declaration. Its does not work.

What am I doing wrong?

Thanks

EM

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
pass combobox as argment to procedure Hokievandal Excel Programming 6 November 23rd 06 11:54 PM
pass paramter to SQL server stored procedure Souris Excel Programming 1 October 22nd 05 11:47 AM
How to pass sheet reference to a procedure djd Excel Programming 1 September 23rd 05 04:17 PM
How to pass a variable from Form back to calling procedure John[_111_] Excel Programming 4 August 21st 05 03:54 PM
Pass switch to Main procedure Bob Phillips[_6_] Excel Programming 0 August 3rd 05 11:23 PM


All times are GMT +1. The time now is 08:27 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"