RE: Opening Access database



Hi Matt,

Here's a Shell function method, but it will give you limited automation
control over the application. You will get the Program ID (as can be seen in
the Task Manager), and you can use more Shell commands to terminate the
application etc, but I'm not sure about controlling it.

Dim ProgID As Double
Const MAXIMIZE_WINDOW As Integer = 3
ProgID = Shell("C:\Program files\.. ..\MSAccess.exe", MAXIMIZE_WINDOW)

Another way would be to reference the Access Object Model from within your
Excel project (in the VBE - Tools>>References select Microsoft Access
(version) Object Library. Once that it present you can use Access automation
in your project:

Dim appAccess As Access.Application
Set appAccess = CreateObject("Access.Application")
appAccess.Visible = True

You can then control the application using Access objects and methods, but I
haven't found anything similar to Excel's Application.WindowState =
xlMaximized. There is a command: appAccess.DoCmd.Maximize, but this only
maximizes the project window within the Access main window, it still won't
maximize the Access main window.

I will look into seeing if there is a scripting technique by which you
maximize a window after the instance has been created. There for you can use
your CreateObject method, subsequently maximize the window, and then continue
with any automation. If I find a way I will post again...

If the Shell method suffices for you though, let me know.

Sean.

"Launchnet via OfficeKB.com" wrote:

Sorry it took a little while to get back.

I tried your suggestion, but Access still opens, but NOT FULL SCREEN.

Still open for suggestions.

Thanks Matt@Launchnet

SeanC UK wrote:
Hi Matt,

Here's a quick solution (I've yet to find one by using the created object
itself), although I'm not very keen on this method.

oApp.Visible = True
SendKeys "% x"

I know that sometimes quotes etc are replaced in these community
communications, so that is: SendKeys doublequote percent space x doublequote

Anyway, this should work in general, I have tested and it worked for me. It
simply sends ALT space then X to maximise the window. Drawbacks are that you
can't use it when stepping through the code as the VBA editor will remain on
top and you'll be sending the keystrokes to it and not Access. Also, if some
greedy application steals focus (unlikely if you write it straight after
Visible = True), then that app will receive the keystrokes. To test in the
debug environment simply place a breakpoint after the sendkeys and run the
code.

There are other methods, search for Shell Function in the VBA help, which
allow you to run an app from the shell and at the same time you can set the
opening window state. You will get the Prog ID returned, but I don't know if
you'll have enough control over the app as you might require. Also, using the
CreateObject method, the app is killed when the object is killed, but using
the Shell method then you will have to write code specifically to kill the
app when you're done.

If I find a method using the object directly then I'll post again. Hope this
helps a bit.

Sean.

The following code works fine, except that the database opens in a small
window. I want it to always open full screen. Can someone take a look and
[quoted text clipped - 22 lines]

End Sub

--
Please take a look at www.openoursite.com Click on: "Keywords" and then
Click on "Matt's Story" and if you are a man, you should be very happy that
you read my story. God Bless for everyones help.

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/excel-programming/200707/1


.



Relevant Pages

  • Re: SendKeys Method when Computer is Locked
    ... "handle" of the child window you are interested in. ... unless the control has focus, ... app to respond. ... Personally I prefer the system api approach. ...
    (microsoft.public.scripting.wsh)
  • Re: Automated GUI testing
    ... Having this ideas in mind you can succeed if you control the program ... naming can make your job of locating the proper window and control ... >1) Window Definitions Scripts ... This definition must be 'tied' to the actual app windows, ...
    (microsoft.public.vc.mfc)
  • Re: MORE Lyle Blake Info......
    ... >control with a static window beside it to show the percentage. ... The lightweight controls will be part of the DLL ... unloaded - the DLL might be unloaded without the App terminating ...
    (comp.lang.pascal.delphi.misc)
  • Re: Window closed event?
    ... You can then add a method to notify the user control ... >>> In a windows forms app how do you know a window is closing? ... >>> I have timer object that appears to be firing after the window is ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Dude, wheres my network?
    ... I opened a shell and typed man sys-unconfig and there it was. ... window, ... you have a window for running commands, ... If you know the app name and path, ...
    (comp.unix.solaris)