Need to maximize the access application window at the opening (not theform)

From a .NET 2003 application I open an Access application. I want the access application window to be maximize at the opening, but not the form.

I found this code but I don't know how to use it.

I put this code in a module, but I don't know how to point my AutoExec on it.

-------------------------------------------------------------------------------------------------------------------------
Public Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Public Const SW_MAXIMIZE = 3


Put this call in the autoexec of the database to maximize:
(This is for a code module. If your autoexec macro doesn't call code, adjust this accordingly for a macro)

  Call ShowWindow(hWndAccessApp, SW_MAXIMIZE)
----------------------------------------------------------------------------------------------------------------------------

And if there's a way to do this in VB.NET that will be better.

Thank you very much
Function Open()
 
       
        Try
            Static acc As Microsoft.Office.Interop.Access.Application
 
            Dim db As dao.Database
 
            acc = New Microsoft.Office.Interop.Access.Application
 
            acc.Visible = True
            db = acc.DBEngine.OpenDatabase(m_cheminBase, False, False, ObtenirInfoConnexion(2))
            acc.OpenCurrentDatabase(m_cheminBase)
 
            db.Close()
            db = Nothing
 
        Catch ex As Exception
            MsgBox("Une erreur est survenue lors de l'ouverture de la base : " & ex.Message & " " & ex.Source)
        End Try
 
End Function

Open in new window

l-ipseAsked:
Who is Participating?
 
matthewrhoadesCommented:
Try this:
Function Open()
 
       
        Try
            Static acc As Microsoft.Office.Interop.Access.Application
 
            Dim db As dao.Database
 
            acc = New Microsoft.Office.Interop.Access.Application
 
            acc.Visible = True
            acc.runCommand 10
            db = acc.DBEngine.OpenDatabase(m_cheminBase, False, False, ObtenirInfoConnexion(2))
            acc.OpenCurrentDatabase(m_cheminBase)
 
            db.Close()
            db = Nothing
 
        Catch ex As Exception
            MsgBox("Une erreur est survenue lors de l'ouverture de la base : " & ex.Message & " " & ex.Source)
        End Try
 
End Function

Open in new window

0
 
l-ipseAuthor Commented:
It can't be as simple as that!

thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.