View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Detect macros in an Excel file

Correct


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Tom Ogilvy" wrote in message ...
Gleam,

If you put that command in a module in xl2003 and then did Debug = Compile
VBAProject it does not raise an error. The error only occurs if the code
attempts to execute the commend. I believe Ron is saying he has designed
his code so that command isn't executed except in xl2007. So obviously it
doesn't provide any functionality (you can't use it to check for code) in
versions earlier than 2007.

--
Regards,
Tom Ogilvy


"Ron de Bruin" wrote in message
...
Hi Gleam

The macro examples on my site compile OK
See How I test the application version in the code

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Gleam" wrote in message
...
I am not sure what you mean by "It compile in older versions " as the
command

Debug.Print ActiveWorkbook.hasvbproject

does not work in 2003. It is good to know that Microsoft have improved
things as this would be a good portable solution.

"Ron de Bruin" wrote:

It is useful in 2007, I use it in my mail code examples and on this
SaveAs page
http://www.rondebruin.nl/saveas.htm

It compile in older versions so the macro can be used in all versions


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Ron de Bruin" wrote in message
...
Thanks Tom

Added in xl2007?
Yes

Workbook.HasVBProject Property
Returns a Boolean that represents whether a workbook has an attached
Microsoft Visual Basic for Applications project. Read-only
Boolean.

Version Added: Excel 2007


I get used to 2007<g
Is that good or bad ?



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Tom Ogilvy" wrote in message
...
Added in xl2007?

--
Regards,
Tom Ogilvy

"Ron de Bruin" wrote in message
...
You can use this to test it

If ActiveWorkbook.HasVBProject then ...............

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Gleam" wrote in message
...
I am using macros in one file to audit another file. The second file
should not have any macros. Is there a way I can detect
this?