View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Accessing VBProject Property

What is the security setting in excel/the workbook. Is programmatic access
granted to the VBE? Is the project unprotected?

--
Regards,
Tom Ogilvy

"Peter" wrote in message
...
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