Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
pass combobox as argment to procedure | Excel Programming | |||
pass paramter to SQL server stored procedure | Excel Programming | |||
How to pass sheet reference to a procedure | Excel Programming | |||
How to pass a variable from Form back to calling procedure | Excel Programming | |||
Pass switch to Main procedure | Excel Programming |