LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default Open book, check for macros, close book

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










 
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
copy worksheets to new book without linking to original book Lori Excel Discussion (Misc queries) 2 March 4th 09 04:46 PM
to disconnect a destination book from a source book officegirl Excel Discussion (Misc queries) 4 December 10th 07 09:28 PM
default template (book.xlt) doesn't close Michael Excel Discussion (Misc queries) 3 December 2nd 05 05:13 PM
Copy and paste ranges from a close book using Validation stakar[_19_] Excel Programming 0 June 24th 04 02:37 PM
close work book via macro Sunil Patel Excel Programming 3 January 7th 04 09:56 PM


All times are GMT +1. The time now is 04:51 PM.

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

About Us

"It's about Microsoft Excel"