View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Peter[_44_] Peter[_44_] is offline
external usenet poster
 
Posts: 5
Default Accessing VBProject Property

Help!

I have a very simple subroutine to get me a list of macros in the current
excel workbook. When the code runs I get a runtime error as follows:

VBProject <error: an exception of type:
{System.Runtime.InteropServices.COMException} occurred
Microsoft.Vbe.Interop.VBProject

The code is listed below.

Any ideas?

I am running the code under Visual Studio.

Peter

Sub ListModules()

Dim VBComp As Microsoft.Vbe.Interop.VBComponent

Dim Msg As String

Dim wb As Excel.Workbook

wb = m_ThisApplication.ActiveWorkbook

For Each VBComp In m_ThisApplication.ActiveWorkbook.VBProject.VBCompo nents

.........

Next VBComp

MsgBox(Msg)

End Sub