Link to home
Start Free TrialLog in
Avatar of Dale Fye
Dale FyeFlag for United States of America

asked on

Hide VBE Window when searching code modules

I'm implementing some code that will search all of the code modules (not form or report modules) to determine whether a specific function is defined in the database.  The code I'm using works fine, thanks to the code posted by JDettman in this post
    Set db = CurrentDb
    Set ctr = db.Containers("Modules")
    
    For Each doc In ctr.Documents
    
        DoCmd.OpenModule doc.Name
        Set myMod = Modules(doc.Name)
        
        Debug.Print myMod.Name
        Do Until myMod.Find(OnAction, StartLine, StartColumn, EndLine, EndColumn) = False
            If myMod.Find("Function", StartLine, 0, StartLine + 1, 0) Then
                bFound = True
            ElseIf myMod.Find("Sub", StartLine, 0, StartLine + 1, 0) Then
                bFound = True
            Else
                StartLine = EndLine
                StartColumn = EndColumn
                EndLine = Empty
                EndColumn = Empty
            End If
            If bFound Then Exit For
        Loop
            
    Next
    
    IsValidFunction = bFound

Open in new window

but opens the VBE window as soon as it hits the first

DoCmd.OpenModule doc.Name

command.  Is there a way to keep the VBE Window hidden during this process?
SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
When Rick's F&R searches modules, the VBE window does flash ...
Avatar of Dale Fye

ASKER

Yeah, neither of those worked, just generated errors.  I think you are right, if Rick hasn't figure it out, what makes me think that I would be able to in this short a period of time.

Check your mail, sending you another version
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Joe,

Tried that one too.  You cannot search the modules unless you first open the module (tried and didn't work) and that line generates an error if the VBE.MainWindow.Visible = False, at least it did on 2007.

This really isn't critical, since developers are going to normally be in design view when creating the shortcut menus, anyway.  I just didn't like the visual of all those windows opening in the VBE.
I see.
I was able to install Add In here at work ... messing with it now.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Jim ... he already tried MainWindow ...

mx
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
None of the solutions actually resolved the issue, but they pointed me in the right direction.  In the end, I had to accept that what I wanted to do is not currently possible.