Link to home
Start Free TrialLog in
Avatar of olangotang
olangotangFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Minimize Access application using VBA

I need to minimize access application so there is just my Desktop displayed.

I'm trying to automate reports from a shelled program, as this program has no automated controls and can't be controled by send keys. I've writen a short VBA program to control the mouse, this works fine in excel as i can minimize the whole application. But i can not achive the same effect in access.

e.g in excel Application.Minimize
the docmd.Minimize just minimizes the database window not the whole application.

Thank you
Avatar of Natchiket
Natchiket
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER CERTIFIED SOLUTION
Avatar of stevbe
stevbe

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
Avatar of bczingo
bczingo

Declare Function FlashWindow Lib "user32" (ByVal hWnd As Long, ByVal bInvert As Long) As Long
Private Type FLASHWINFO
    cbSize As Long   ' size of structure
    hWnd As Long     ' hWnd of window to use
    dwFlags As Long  ' Flags, see below
    uCount As Long   ' Number of times to flash window
    dwTimeout As Long    ' Flash rate of window in milliseconds. 0 is default.
End Type
Private Declare Function FlashWindowEx Lib "user32" _
                                       (FWInfo As FLASHWINFO) As Boolean
Private Declare Sub Sleep Lib "kernel32" _
                          (ByVal dwMilliseconds As Long)

Public Sub callThis()
    Dim hWnd As Long
    Dim dummy As Long
    Dim RetVal As Integer
    Dim FWInfo As FLASHWINFO
    Dim howmanyFlashes As Long
    howmanyFlashes = 10000
    DoCmd.RunCommand acCmdAppMinimize
    hWnd = Application.hWndAccessApp
    Const FLASHW_STOP = 0
    Const FLASHW_CAPTION = 1
    Const FLASHW_TRAY = 2
    Const FLASHW_ALL = FLASHW_CAPTION Or FLASHW_TRAY
    Const FLASHW_TIMER = 4
    Const FLASHW_TIMERNOFG = 12
    ' Fill the structure:
    With FWInfo
        .cbSize = 20
        .hWnd = hWnd
        .dwFlags = FLASHW_ALL
        .uCount = howmanyFlashes
        .dwTimeout = 0
    End With

    ' Allow time to cover the window:
    Sleep (2000)
    ' call the function:
    RetVal = FlashWindowEx(FWInfo)
End Sub