PC Review


Reply
Thread Tools Rate Thread

Detect macros in an Excel file

 
 
=?Utf-8?B?R2xlYW0=?=
Guest
Posts: n/a
 
      16th Mar 2007
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?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sk1C?=
Guest
Posts: n/a
 
      17th Mar 2007
Some information on dealing w/the VBProject on Chip's site:

http://www.cpearson.com/excel/vbe.htm#ListAllInProject

I've never had the need to deal w/the VBProject programmatically, but maybe
this will give you a place to start.

"Gleam" wrote:

> 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?

 
Reply With Quote
 
pfsardella@yahoo.com.nospam
Guest
Posts: n/a
 
      17th Mar 2007
http://www.google.com/groups?hl=en&l...4a6e1da&rnum=1

You could try a couple of the suggestions in this link.

HTH
Paul
-------------------------------------------------------------------

>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?


 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      17th Mar 2007
You can use this to test it

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

--

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


"Gleam" <(E-Mail Removed)> wrote in message news:9089ED1C-F0B7-47F3-AB6A-(E-Mail Removed)...
>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?

 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      17th Mar 2007
Added in xl2007?

--
Regards,
Tom Ogilvy

"Ron de Bruin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You can use this to test it
>
> If ActiveWorkbook.HasVBProject then ...............
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.nl/tips.htm
>
>
> "Gleam" <(E-Mail Removed)> wrote in message
> news:9089ED1C-F0B7-47F3-AB6A-(E-Mail Removed)...
>>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?



 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      17th Mar 2007
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Added in xl2007?
>
> --
> Regards,
> Tom Ogilvy
>
> "Ron de Bruin" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> You can use this to test it
>>
>> If ActiveWorkbook.HasVBProject then ...............
>>
>> --
>>
>> Regards Ron de Bruin
>> http://www.rondebruin.nl/tips.htm
>>
>>
>> "Gleam" <(E-Mail Removed)> wrote in message news:9089ED1C-F0B7-47F3-AB6A-(E-Mail Removed)...
>>>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?

>
>


 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      17th Mar 2007
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> Added in xl2007?
>>
>> --
>> Regards,
>> Tom Ogilvy
>>
>> "Ron de Bruin" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>>> You can use this to test it
>>>
>>> If ActiveWorkbook.HasVBProject then ...............
>>>
>>> --
>>>
>>> Regards Ron de Bruin
>>> http://www.rondebruin.nl/tips.htm
>>>
>>>
>>> "Gleam" <(E-Mail Removed)> wrote in message news:9089ED1C-F0B7-47F3-AB6A-(E-Mail Removed)...
>>>>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?

>>
>>

>

 
Reply With Quote
 
=?Utf-8?B?R2xlYW0=?=
Guest
Posts: n/a
 
      18th Mar 2007
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> >> Added in xl2007?
> >>
> >> --
> >> Regards,
> >> Tom Ogilvy
> >>
> >> "Ron de Bruin" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> >>> You can use this to test it
> >>>
> >>> If ActiveWorkbook.HasVBProject then ...............
> >>>
> >>> --
> >>>
> >>> Regards Ron de Bruin
> >>> http://www.rondebruin.nl/tips.htm
> >>>
> >>>
> >>> "Gleam" <(E-Mail Removed)> wrote in message news:9089ED1C-F0B7-47F3-AB6A-(E-Mail Removed)...
> >>>>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?
> >>
> >>

> >

>

 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      18th Mar 2007
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" <(E-Mail Removed)> wrote in message news:BB643D02-D7F2-4BD7-9C64-(E-Mail Removed)...
>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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> > 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> >> Added in xl2007?
>> >>
>> >> --
>> >> Regards,
>> >> Tom Ogilvy
>> >>
>> >> "Ron de Bruin" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> >>> You can use this to test it
>> >>>
>> >>> If ActiveWorkbook.HasVBProject then ...............
>> >>>
>> >>> --
>> >>>
>> >>> Regards Ron de Bruin
>> >>> http://www.rondebruin.nl/tips.htm
>> >>>
>> >>>
>> >>> "Gleam" <(E-Mail Removed)> wrote in message news:9089ED1C-F0B7-47F3-AB6A-(E-Mail Removed)...
>> >>>>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?
>> >>
>> >>
>> >

>>


 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      18th Mar 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:BB643D02-D7F2-4BD7-9C64-(E-Mail Removed)...
>>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" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>> > 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" <(E-Mail Removed)> wrote in message
>>> > news:(E-Mail Removed)...
>>> >> Added in xl2007?
>>> >>
>>> >> --
>>> >> Regards,
>>> >> Tom Ogilvy
>>> >>
>>> >> "Ron de Bruin" <(E-Mail Removed)> wrote in message
>>> >> news:(E-Mail Removed)...
>>> >>> You can use this to test it
>>> >>>
>>> >>> If ActiveWorkbook.HasVBProject then ...............
>>> >>>
>>> >>> --
>>> >>>
>>> >>> Regards Ron de Bruin
>>> >>> http://www.rondebruin.nl/tips.htm
>>> >>>
>>> >>>
>>> >>> "Gleam" <(E-Mail Removed)> wrote in message
>>> >>> news:9089ED1C-F0B7-47F3-AB6A-(E-Mail Removed)...
>>> >>>>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?
>>> >>
>>> >>
>>> >
>>>

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detect macro in excel file without opening it Boss Microsoft Excel Programming 6 28th Apr 2010 04:03 PM
Detect file format (version) of Excel file Alan Microsoft Excel Programming 1 28th Oct 2008 07:55 PM
Detect if an excel file is open =?Utf-8?B?SkNQ?= Microsoft Excel Programming 1 1st Sep 2007 11:34 AM
Detect if an Excel file is open =?Utf-8?B?SmFrb2IgTGl0aG5lcg==?= Microsoft Dot NET Framework 2 6th Nov 2006 07:26 AM
Excel/automation Gurus., please help... extract macros from excel and adding new macros into an excel sheet. OhMyGaw Microsoft C# .NET 3 10th Aug 2005 01:52 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:37 AM.