ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programmatically finding out if Excel macros are enabled. (https://www.excelbanter.com/excel-programming/325495-programmatically-finding-out-if-excel-macros-enabled.html)

Zhwgnon Flrq

Programmatically finding out if Excel macros are enabled.
 
How can I find out through VB 6.0 whether macros are enable in an Excel 2003
application?

I tried the following but it does not work:

Set ea = CreateObject ("Excel.Application")

' test.xls has macros
Set wb = ea.Workbooks.Open ("e:\test.xls")

' This line bombs out
MsgBox (ea.VBE.VBProjects.Count)

Any help will be appreciated. Thanks.

Tim Williams

Programmatically finding out if Excel macros are enabled.
 
Have you added a reference to the VBE library?
What is the text of the error you get?

Tim

--
Tim Williams
Palo Alto, CA


"Zhwgnon Flrq" <Zhwgnon wrote in message
...
How can I find out through VB 6.0 whether macros are enable in an Excel

2003
application?

I tried the following but it does not work:

Set ea = CreateObject ("Excel.Application")

' test.xls has macros
Set wb = ea.Workbooks.Open ("e:\test.xls")

' This line bombs out
MsgBox (ea.VBE.VBProjects.Count)

Any help will be appreciated. Thanks.




Zhwgnon Flrq[_2_]

Programmatically finding out if Excel macros are enabled.
 
I got the solution.

The text of the error message was: Programmatic Access to Visual Basic
Project is unsafe.

The code was written against Excel 2000, but in XP and 2003, security has
been enhanced. The solution is documented he
http://support.microsoft.com/kb/q282830/

"Tim Williams" wrote:

Have you added a reference to the VBE library?
What is the text of the error you get?

Tim

--
Tim Williams
Palo Alto, CA


"Zhwgnon Flrq" <Zhwgnon wrote in message
...
How can I find out through VB 6.0 whether macros are enable in an Excel

2003
application?

I tried the following but it does not work:

Set ea = CreateObject ("Excel.Application")

' test.xls has macros
Set wb = ea.Workbooks.Open ("e:\test.xls")

' This line bombs out
MsgBox (ea.VBE.VBProjects.Count)

Any help will be appreciated. Thanks.






All times are GMT +1. The time now is 06:27 AM.

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