Here is how to do with API calls, I use to transfer captured screen
or form bmp from clipboard to a word doc that is then emailed as an
error message.
'_______________________________________________________
' Snap a picture of the screen and send error messages,
' screen picture and tasklist to a word document
'________________________________________________________
Private Const VK_LWIN = &H5B 'Left window button
Private Const VK_RETURN = &HD 'ENTER key
Private Const VK_SHIFT = &H10 'SHIFT key
Private Const VK_CONTROL = &H11 'CTRL key
Private Const VK_MENU = &H12 'ALT key
Private Const VK_PAUSE = &H13 'PAUSE key
Private Const VK_CAPITAL = &H14 'CAPS LOCK key
Private Const VK_SNAPSHOT = &H2C 'Print Screen
Private Const VK_APPS = &H5D
'Applications key on a Microsoft Natural Keyboard
'from http://support.microsoft.com/view/dev.asp?kb=242971
Const GW_HWNDFIRST = 0
Const GW_HWNDNEXT = 2
Private Const KEYEVENTF_KEYUP = &H2
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwflags As Long, ByVal dwExtraInfo As
Long)
Private Declare Function GetWindow Lib "user32" _
(ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetParent Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function GetWindowTextLength Lib _
"user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" _
Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal _
lpString As String, ByVal cch As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetFocusAPI Lib "user32" Alias "SetFocus" _
(ByVal hwnd As Long) As Long
Sub SnapPrintForm()
'use the following code inside form or focused window
'to simulate the Alt / PrintScreen = key combination:
' programmatically press the ALT key
keybd_event VK_MENU, 0, 0, 0
' then press and then release the PrtScreen key
keybd_event VK_SNAPSHOT, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
' and finally release the ALT Key
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
End Sub
Sub SnapPrintScreen()
'To print the entire screen (rather than the current focused window
'programmatically press the ALT key
keybd_event VK_MENU, 0, 0, 0
' then press and then release the PrtScreen key
keybd_event VK_SNAPSHOT, 1, 0, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
' and finally release the ALT Key
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
' The second argument for the keybd_event call is the hardware scan
code,
' and, in this case, you could use the value 1. This may have to
change
with Win 2000
' However, applications should not use this scan code according to
Microsoft
' The screen is now captured in the clipboard as a bmp
End Sub
Sub OpenWindowsHelp()
' Open the Windows Help
'
' You can use the same technique to programmatically "press" any other
' key, including Shift, Ctrl, Alt and keys combinations that can't be
' simulated through SendKeys
' programmatically press the Windows key
keybd_event VK_LWIN, 0, 0, 0
' then press and then release the F1 key
keybd_event vbKeyF1, 0, 0, 0
keybd_event vbKeyF1, 0, KEYEVENTF_KEYUP, 0
' and finally release the Windows Key
keybd_event VK_LWIN, 0, KEYEVENTF_KEYUP, 0
End Sub
Sub CloseAllWindows()
' Minimize all open windows
'Const acaltMask
' programmatically press the Windows key
keybd_event VK_LWIN, 0, 0, 0
' then press and then release the M key
keybd_event vbKeyM, 0, 0, 0
keybd_event vbKeyM, 0, KEYEVENTF_KEYUP, 0
' and finally release the Windows Key
keybd_event VK_LWIN, 0, KEYEVENTF_KEYUP, 0
End Sub
--- In [EMAIL PROTECTED], "phoogenb" <[EMAIL PROTECTED]> wrote:
>
> Does the screen need to go to the clipboard? If not, you can just
make
> a button that prints the form to the printer. In this case, you
could
> use DoCmd.PrintOut. Otherwise, you're going to need to use some
> Windows API calls.
>
> Peter Hoogenboom
>
> --- In [EMAIL PROTECTED], "sfukuda21" <sfukuda@> wrote:
> >
> > OK
> >
> > Here's an easy one. I've looked in the manuals and can't seem to
> find
> > what I need. I have a form (screen) full of data and my users
(being
> > users) want a single button to create a print screen. Instead of
Alt-
> > Print Scrn, they want a single button push. I'm sure it can be
done,
> > just con't know the actual code syntax.
> >
> >
> > Thanks in advance for any help
> >
>