Home > Software design >  How to maximize Access Application window using C#?
How to maximize Access Application window using C#?

Time:06-15

I'm using Microsoft.Office.Interop.Access to open access db using code like this :

Access.Application AccApp = new Access.Application();
AccApp.Visible = true;
AccApp.OpenCurrentDatabase(databasePathAndFileName, false, databasePassword);

The point is when access opens the window's size is small I need to maximize the access window after opening it . Thanks

CodePudding user response:

The VBA command for this is

DoCmd.RunCommand acCmdAppMaximize

which should be callable from C# interop as follows:

const int acCmdAppMaximize = 10;
AccApp.DoCmd.RunCommand(acCmdAppMaximize);

Obviously, you can (and should) skip the redeclaration of the acCmdAppMaximize constant if it is already provided by the interop library.

CodePudding user response:

Thanks to @Heinzi who pointed me to the right direction , This worked for me :

Microsoft.Office.Interop.Access.Application AccApp = new Microsoft.Office.Interop.Access.Application();
AccApp.Visible = true;
AccApp.OpenCurrentDatabase("D:\\Settings.accdb", false, "017014A");
AccApp.RunCommand(AcCommand.acCmdAppMaximize);
  • Related