Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Hide VBE Window when searching code modules

Posted on 2014-02-17
11
Medium Priority
?
580 Views
Last Modified: 2014-02-27
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?
0
Comment
Question by:Dale Fye
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
11 Comments
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 1200 total points
ID: 39866460
Maybe
vbe.ActiveWindow.Visible = False

or

vbe.ActiveWindow.Close


mx
0
 
LVL 75
ID: 39866471
When Rick's F&R searches modules, the VBE window does flash ...
0
 
LVL 48

Author Comment

by:Dale Fye
ID: 39867225
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
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 1200 total points
ID: 39867981
Well ... what I meant by 'flash' was ... each module window Opens/Closes ... so when done .... all are closed.

There has to be a way ...
Experiment with the SetFocus option of ActiveWindow, etc ...
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 1200 total points
ID: 39868249
OK ... I tried this with a bunch of code windows open, and they all closed:

VBE.MainWindow.Visible = False
0
 
LVL 48

Author Comment

by:Dale Fye
ID: 39868268
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.
0
 
LVL 75
ID: 39868290
I see.
I was able to install Add In here at work ... messing with it now.
0
 
LVL 58

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 800 total points
ID: 39868645
Try:

Application.VBE.MainWindow.Visible = False

If that doesn't do it for you (you'll get the flashing), then you can lock the window from updates with an API call (below and note not tested).  Make sure you unlock the window when done.

Jim.

Option Compare Database

Public Declare Function api_LockWindow32 Lib "user32" Alias "LockWindowUpdate" (ByVal hwndLock As Long) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWndParent As Long, ByVal hWndChid As Long, ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Public Sub atLockWindow(TrueOrFalse As Boolean)

    Dim Status&, hWndTarget&
   
10  On Error Resume Next
20  If TrueOrFalse = True Then
30      hWndTarget =  FindWindowEx(0, 0, "wndclass_desked_gsk", Application.VBE.MainWindow.Caption)  
40      If hWndTarget <> 0 Then Status = api_LockWindow32(hWndTarget)
50  Else
60      Status = api_LockWindow32(0)
70  End If

End Sub
0
 
LVL 75
ID: 39868662
Jim ... he already tried MainWindow ...

mx
0
 
LVL 48

Accepted Solution

by:
Dale Fye earned 0 total points
ID: 39880038
Ended up just accepting that in order to actually search the modules, you have to open the module, and you cannot do that with the VB editor window closed.  Watching the windows open is not that big of a deal anyway.
0
 
LVL 48

Author Closing Comment

by:Dale Fye
ID: 39891397
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.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question