Hi People. Here is the code I have been using:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_SNAPSHOT = &H2C
Private Const VK_MENU = &H12
Sub AltPrintScreen()
keybd_event VK_MENU, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
End Sub
Sub ClearClipboard()
Dim MyData As DataObject
Set MyData = New DataObject
MyData.SetText ""
MyData.PutInClipboard
End Sub
Private Sub cmdSubmit_Click()
Call ClearClipboard
'WordBasic.SendKeys ("%{prtsc}")
' ALT + Print Screen
WordBasic.SendKeys ("%{1068}")
UserForm1.Hide
'CTRL + v (Paste)
WordBasic.SendKeys ("^v")
Unload Me
End Sub
What this does is when the user clicks on the submit button, it pastes in a copy of the MS Word screen with the form inside in the body of the Word Document.
I heard that the Sendkeys method was unreliable and unpredictable, but I was hoping simulating these keystrokes would do the trick. Any suggestion? DAVE