Is there way to find Office files on share which contain macros?

Thanks in advance for reading this. if you think the question belongs in a different forum, please let me know. 

Our organization will be upgrading everyone from Office 2003 to Office 2013. We are aware of a few Excel 2003 files having incompatibility issues with Office 2013, specifically macros (vba code) are going through a conversion/evaluation process.

I wanted to do a search on our file shares for other files that we involved in the conversion may not be aware of which also have VBA code in them. Is there a way to search, either using Windows 8's File Explorer or Visual Basic, to locate all MS Office files having VBA code in

March 24th, 2015 12:22pm

Hi,

As far as I know, if the files include some macros, they are usually saved as XLSM format. Thus, we may filter this format by using Windows 8's File Explorer first. But, not all the XLSM files have the macros, we may use some VBA function to do further filter.

Sample code

One:

Function FoundMarco(f) As Boolean

Dim vbc As VBComponent, i As Long

Dim wbk As Workbook

Application.EnableEvents = False

Set wbk = Workbooks.Open(f)

FoundMarco = False

For Each vbc In wbk.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

FoundMarco = True

Exit For

End If

Next

End With

If FoundMarco Then Exit For

Next

Application.EnableEvents = True

wbk.Close

End Function

Two:
Public Function blnCod() As Boolean
 Dim j As Integer
 For j = 1 To ActiveWorkbook.VBProject.VBComponents.Count
     If ActiveWorkbook.VBProject.VBComponents(j).CodeModule.CountOfLines > 2 Then
        blnCod = True
        Exit For
     End If
 Next j
 End Function

If you have any further question about using VBA function, I recommend you post the question to MSDN forum:

http://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alltypes&sort=lastpostdesc

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

Regards,

George Zhao
TechNet Community Support

Free Windows Admin Tool Kit Click here and download it now
March 24th, 2015 11:20pm

Thank you George! I will post in the other forum you mention; I'm just trying to find my way among these forums.

Our files are saved as XLS, even for the users who have Excel 2013; some here are still using Excel 2003, we're in middle of transitioning to newer PCs.

March 25th, 2015 10:24am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics