Tiz nearly bedtime here too, but...
1. in the Visual Basic Editor, goto Tools, References, and select Microsoft
Visual Basic For Applications Extensibility from the list.
2. You got caught out by some word wrapping.
delete the comment that looks like this
'requires a reference to Microsoft Visual Basic For Applications
Extensibility
3. In Excel, goto Tools, Options, Security, Macro Security, Trusted Sources,
and select Trust Access to Visual Basic Project.
4. Try it again and step through it using the F8 key in the editor to see
what is happening if it still returns incorrect results.
G'night
Robin Hammond
www.enhanceddatasystems.com
"CLR" wrote in message
...
Thanks for the help Robin..........
That stuff is 'way over my head........I just took it all and copied it
into
a regular module and put the Function on top of the Sub and changed the
file
names to ones I had and ran it..........I got "Compile Error: sub of\r
Function not defined" on the word "Extensibility".........so I REMed it
out
and re-ran and it flies, but I get "TRUE" on every workbook, whether or
not
they have VBA inside..........I don't understand the comment 'requires a
reference to Microsoft Visual Basic For Applications
Extensibility...........obviously I'm doing something wrong, but have no
clue as to what.......'tiz bedtime now, I'll look more tomorrow..........
Thanks again,
Vaya con Dios,
Chuck, CABGx3
"Robin Hammond" wrote in message
...
Chuck,
A simple demo:
Sub Main()
Dim strFile As String
Dim wTest As Workbook
strFile = "C:\Test\Book1.xls"
With ThisWorkbook.Sheets(1)
.Cells(1, 1).Value = strFile
Set wTest = Workbooks.Open(strFile, False)
.Cells(1, 2).Value = fnContainsMacros(wTest)
wTest.Close False
End With
End Sub
Function fnContainsMacros(wTest As Workbook) As Variant
'requires a reference to Microsoft Visual Basic For Applications
Extensibility
On Error GoTo VBAccessDisabled
If wTest.VBProject.VBComponents.Count 0 Then fnContainsMacros = True
On Error GoTo 0
EndRoutine:
Exit Function
VBAccessDisabled:
On Error GoTo 0
fnContainsMacros = "#N/A"
Resume EndRoutine
End Function
HTH,
Robin Hammond
www.enhanceddatasystems.com
"CLR" wrote in message
...
Hi All...........
Still looking for some help on this one, if someone please. Under
macro
control, I wish to open another workbook, check to see if that workbook
contains any macros, and then close that workbook and record the answer
in
the first workbook.
TIA for assistance.........
Vaya con Dios,
Chuck, CABGx3