E
ExcelMonkey
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 here:
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/Forums/en-US/vbgeneral/thread/3193a867-8bd7-47b7-9a1b-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
Microsift Office Newsgroups. Yet when I google it shows up here:
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/Forums/en-US/vbgeneral/thread/3193a867-8bd7-47b7-9a1b-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