LarryClark
Programmer
I'm trying to launch Access from VB for report printing. This much works OK.<br>
<br>
Set ObjAccess = CreateObject("Access.Application")<br>
With ObjAccess<br>
.Visible = True<br>
.OpenCurrentDatabase (MyPath & MyDbname)<br>
RptName = "Whatever"<br>
.DoCmd.OpenReport RptName, 2<br>
.DoCmd.SelectObject 3, RptName 'acReport=3<br>
.DoCmd.Maximize<br>
End With<br>
<br>
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.<br>
<br>
I have tried using SendKeys, but I cannot get the right window activated:<br>
AppActivate "Microsoft Access"<br>
SendKeys "% X"<br>
(I was running the above before opening a document, and my tests seemed to indicate that the window title contained only "Microsoft Access".)<br>
<br>
I also tried inserting the following:<br>
Declare Function ShowWindow Lib "User32" _<br>
(ByVal hWnd As Long, ByVal nCmdShow As Long)<br>
Global Const SW_MAXIMIZE As Long = 3<br>
hWndAccess = .hWndAccessApp<br>
Temp = ShowWindow(hWndAccess, SW_MAXIMIZE)<br>
When I run this, the ShowWindow produces a "bad DLL calling convention." What am I missing?<br>
<br>
Alternatively, I'll settle for any technique that works!<br>
Thanks for any suggestions.
<br>
Set ObjAccess = CreateObject("Access.Application")<br>
With ObjAccess<br>
.Visible = True<br>
.OpenCurrentDatabase (MyPath & MyDbname)<br>
RptName = "Whatever"<br>
.DoCmd.OpenReport RptName, 2<br>
.DoCmd.SelectObject 3, RptName 'acReport=3<br>
.DoCmd.Maximize<br>
End With<br>
<br>
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.<br>
<br>
I have tried using SendKeys, but I cannot get the right window activated:<br>
AppActivate "Microsoft Access"<br>
SendKeys "% X"<br>
(I was running the above before opening a document, and my tests seemed to indicate that the window title contained only "Microsoft Access".)<br>
<br>
I also tried inserting the following:<br>
Declare Function ShowWindow Lib "User32" _<br>
(ByVal hWnd As Long, ByVal nCmdShow As Long)<br>
Global Const SW_MAXIMIZE As Long = 3<br>
hWndAccess = .hWndAccessApp<br>
Temp = ShowWindow(hWndAccess, SW_MAXIMIZE)<br>
When I run this, the ShowWindow produces a "bad DLL calling convention." What am I missing?<br>
<br>
Alternatively, I'll settle for any technique that works!<br>
Thanks for any suggestions.