Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Loop through VBA Compenents in Excel via VB.Net

I keep trying to post this in this forum but the moderators keeping moving it
other formums PLEASE STOP DOING THIS.

I amtrying to loop through some VB Project components in Excel via .NET

In VBA I would do the following:
Dim VBComp As VBIDE.VBComponent
For Each VBComp In ThisWorkbook.VBProject.VBComponents

Next

In .Net I am doing the following:
Dim VBComp As Microsoft.Vbe.Interop.Component
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))."

I thought I may have found a response regarding the use of an explicit cast
at this link:

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

However I cannot get this to work as VBIDE.VBProject does not work in .Net.

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
returning back to loop check condition without completing the loop ashish128 Excel Programming 13 April 3rd 08 12:53 PM
Loop to Filter, Name Sheets. If Blank, Exit Loop ryguy7272 Excel Programming 3 February 5th 08 03:41 PM
Naming Worksheets - Loop within a loop issue klysell Excel Programming 5 March 29th 07 05:48 AM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM


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