ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Accessing VBProject Property (https://www.excelbanter.com/excel-programming/311524-accessing-vbproject-property.html)

Peter[_44_]

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



Tom Ogilvy

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






All times are GMT +1. The time now is 04:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com