Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to determin a Excel file has Macro

Hi All:
I have a lot of Excel files. I hope to demarcate
the Excel files that have macro. Is there any tools or how
to program ?


Thanks
Best Regards
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default How to determin a Excel file has Macro

Winston,

There is no way to determine whether a workbook has a macro
or not without attempting to open it.
If you set your security level to "Medium", you'll be prompted
to "Enable Macros" if one is found in the workbook.
Be aware though that getting the prompt doesn't necessarily
mean that there "are" macros in the workbook. An empty module
or some errant code in the workbook will also trigger the prompt.

John

"Winston Lee" wrote in message
...
Hi All:
I have a lot of Excel files. I hope to demarcate
the Excel files that have macro. Is there any tools or how
to program ?


Thanks
Best Regards



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default How to determin a Excel file has Macro

Hi

I have never seen code like that. But try opening a few small Excel files in
Notepad -there are some very distinct ascii words in files that contain macros. So maybe
this can be done, and if "lot of files" is a big lot then maybe it's worth the effort.

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Winston Lee" wrote in message
...
Hi All:
I have a lot of Excel files. I hope to demarcate
the Excel files that have macro. Is there any tools or how
to program ?


Thanks
Best Regards



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default How to determin a Excel file has Macro

This would be very difficult to get working accurate first cut.

I would inspect the code modules of each VBComponent inside the workbook.
Try doing a lookup on ProcOfLine. You could loop through each line checking
for at least one procedure. If one exists you could assume the workbook has
macros?



"Winston Lee" wrote in message
...
Hi All:
I have a lot of Excel files. I hope to demarcate
the Excel files that have macro. Is there any tools or how
to program ?


Thanks
Best Regards



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default How to determin a Excel file has Macro

I thought I would put theory to the test.
You need to add a reference (From Tools menu, References) to "Microsoft
Visual Basic for Applications Extensibility"

Sub testit()
Dim wkb As Workbook, vbc As VBComponent, i As Long, blnFound As Boolean

For Each wkb In Workbooks
blnFound = False
For Each vbc In wkb.VBProject.VBComponents
With vbc.CodeModule
For i = 1 To .CountOfLines
If .ProcOfLine(i, vbext_pk_Get) < "" Or _
.ProcOfLine(i, vbext_pk_Let) < "" Or _
.ProcOfLine(i, vbext_pk_Proc) < "" Or _
.ProcOfLine(i, vbext_pk_Set) < "" Then
blnFound = True
Exit For
End If
Next
End With
If blnFound Then Exit For
Next
MsgBox wkb.Name & ": macros " & IIf(blnFound, "", "not ") & "found"
Next
End Sub


"Rob van Gelder" wrote in message
...
This would be very difficult to get working accurate first cut.

I would inspect the code modules of each VBComponent inside the workbook.
Try doing a lookup on ProcOfLine. You could loop through each line

checking
for at least one procedure. If one exists you could assume the workbook

has
macros?



"Winston Lee" wrote in message
...
Hi All:
I have a lot of Excel files. I hope to demarcate
the Excel files that have macro. Is there any tools or how
to program ?


Thanks
Best Regards







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default How to determin a Excel file has Macro

Hi Winston Lee;
You need:
http://download.microsoft.com/downlo...US/Dsofile.exe
and after, you can use the HasMacros property.
MP

"Winston Lee" a écrit dans le message de
...
Hi All:
I have a lot of Excel files. I hope to demarcate
the Excel files that have macro. Is there any tools or how
to program ?


Thanks
Best Regards



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add macro to Excel-file Arne Hegefors Excel Discussion (Misc queries) 2 January 10th 07 09:08 PM
Determin a telehone number Sean Excel Discussion (Misc queries) 3 August 30th 06 12:49 PM
Excel '00, 1st file has macros, how to stop macro in 2nd file? kaptandrews Excel Discussion (Misc queries) 0 May 24th 06 03:07 PM
Excel Macro To Convert XML File John[_52_] Excel Programming 3 September 4th 03 05:34 PM
Saving an Excel file as a CSV using a Macro doug Excel Programming 2 July 24th 03 03:00 PM


All times are GMT +1. The time now is 05:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"