Opening Access database

L

Launchnet

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
advise me on what code to add ?

Thanks
Matt@Launchnet


Sub NewAccessWithDocument()

'ActiveWorkbook.FollowHyperlink Address:="C:\_Matts Data\0_avp\
avpdatabasesample.mdb"


Dim LPath As String
Dim LCategoryID As Long

'Path to Access database
LPath = "C:\_Matts Data\0_avp\avpdatabasesample.mdb"

'Open Access and make visible
Set oApp = CreateObject("Access.Application")
oApp.Visible = True

'Open Access database as defined by LPath variable
oApp.OpenCurrentDatabase LPath

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
 
G

Guest

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.
 
L

Launchnet via OfficeKB.com

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 said:
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]

--
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
 
G

Guest

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 said:
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 said:
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]

--
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top