Here's some code you can adapt.
Check that it works as you expect on all platforms.
Regards
Geoff
Option Compare Database
Option Explicit
' This code is for Microsoft Access.
' Declare API function:
Public Declare Function SetForegroundWindow Lib "user32" ( _
ByVal hWnd As Long) As Long
Private Sub DemoShowAccess()
' Shows Access Application after
' Automation work completed.
Dim fSuccess As Boolean
On Error GoTo Error_DemoShowAccess
'****************************
' Do Automation work here.
'****************************
' Call the ShowAccess() function (below):
fSuccess = ShowAccess(True)
If Not fSuccess Then
GoTo Exit_DemoShowAccess
End If
' Show message in Access window:
MsgBox "Finished"
Exit_DemoShowAccess:
Exit Sub
Error_DemoShowAccess:
MsgBox Err.Description, vbOKOnly + vbExclamation, _
"Error No: " & Err.Number
Resume Exit_DemoShowAccess
End Sub
Public Function ShowAccess( _
Optional ShowErrorMessage As Boolean = False) As Boolean
' RETURNS:
'
' TRUE if the call to SetForegroundWindow() succeeds;
' otherwise, FALSE.
Dim lngL As Long
' Call API function:
lngL = SetForegroundWindow(Access.Application.hWndAccessApp)
' See if call failed:
If lngL = 0 Then
If ShowErrorMessage Then
MsgBox "The SetForegroundWindow() API function " _
& "returned error number: " & Err.LastDllError, _
vbOKOnly + vbExclamation, "Error Information"
End If
Else
ShowAccess = True
End If
End Function