Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to maximize Access (as Automation Server)

How to maximize Access (as Automation Server)

How to maximize Access (as Automation Server)

I'm trying to launch Access from VB for report printing. This much works OK.

Set ObjAccess = CreateObject("Access.Application")
With ObjAccess
.Visible = True
.OpenCurrentDatabase (MyPath & MyDbname)
RptName = "Whatever"
.DoCmd.OpenReport RptName, 2
.DoCmd.SelectObject 3, RptName 'acReport=3
End With

The last set of instructions maximize the report's MDI child within the Access window. However, I have been unable to maximize the Access window itself.

I have tried using SendKeys, but I cannot get the right window activated:
AppActivate "Microsoft Access"
SendKeys "% X"
(I was running the above before opening a document, and my tests seemed to indicate that the window title contained only "Microsoft Access".)

I also tried inserting the following:
Declare Function ShowWindow Lib "User32" _
(ByVal hWnd As Long, ByVal nCmdShow As Long)
Global Const SW_MAXIMIZE As Long = 3
hWndAccess = .hWndAccessApp
Temp = ShowWindow(hWndAccess, SW_MAXIMIZE)
When I run this, the ShowWindow produces a "bad DLL calling convention." What am I missing?

Alternatively, I'll settle for any technique that works!
Thanks for any suggestions.

RE: How to maximize Access (as Automation Server)

You COULD simply run the SHELL command from VB, starting Access with a suitable macro from the command line. It's cheap, I know, but it works for me...

RE: How to maximize Access (as Automation Server)

That will indeed launch Access, but I won't get back an object handle so that I can perform other actions on it. Once it's launched, I could find it via GetObject, but I would think there'd be a more direct way via CreateObject.

RE: How to maximize Access (as Automation Server)

Microsoft offers a free download of a "snapshot viewer" that allows viewing, printing and e-mailing of access reports without using access. This might be of some help to you in that you could eliminate the need to open access at all.


RE: How to maximize Access (as Automation Server)

Also could try this. For some reason you have to make Two calls to the window to get it to work.

Private Declare Function apiSetForegroundWindow Lib _
"user32" Alias "SetForegroundWindow"(ByVal hwnd As Long) _
As Long

Private Declare Function apiShowWindow Lib "user32" Alias _ "ShowWindow"(ByVal hwnd As Long, ByVal nCmdShow As Long) _
As Long

Private Const SW_MAXIMIZE = 3

Set objAccess = New Access.Application
With objAccess
lngRet = apiSetForegroundWindow(.hWndAccessApp)
lngRet = apiShowWindow(.hWndAccessApp, SW_MAXIMIZE)
'the first call to ShowWindow doesn't seem to do anything
lngRet = apiShowWindow(.hWndAccessApp, SW_MAXIMIZE)
.OpenCurrentDatabase (MyPath & MyDbname)
RptName = "Whatever"
.DoCmd.OpenReport RptName, 2
.DoCmd.SelectObject 3, RptName 'acReport=3
End With

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close