S
Steve
I'm using Office 2000 and 2003
I'm writing a macro to read input from the operator and write the response
to a word document then capture a window from another application like MatLab
and past e that to the same document and repeat this process until the
operator exits by entering X. Everything works with exception of being able
to capture the desired screen. Right now I capture the inputbox screen
because it is the active window. Is there a way to select another window to
become the active window? Also, is there a way to list all the windows that
are open regardless of what application they are associated with. For example
if there is an Explorer, Word, Excel, and Powerpoint windows open can I
identify how many are open and select the one that match a title or
applicaiton? Thank you in advance for your assistance. Following is the
code I'm using.
Option Explicit
Public Declare Sub keybd_event Lib "user32" (ByVal bvk As Byte, ByVal _
bScan As Byte, ByVal dwflags As Long, ByVal dwExtrainfo As Long)
Public Const KEYEVENTF_KEYUP = &H2
Public Const VK_SNAPSHOT = &H2C
Public Const VK_MENU = &H12
Sub ScreenCapture()
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
Do
ansrlen = 0
Answer = InputBox("Enter color and associated number and then " & vbCr & _
"click ""Ok"" ONLY when you are ready to" & vbCr & _
"capture the screen" & vbCr & vbCr & _
"Enter X or x to exit.", "Main Capture")
ansrlen = Len(Answer)
Answer = UCase(Mid(Answer, 1, 1)) & Mid(Answer, 2, ansrlen)
If Answer = "X" Then
confirmX = MsgBox("Select ""Yes"" to confirm termination" & vbCr &
vbCr & _
"Select ""No"" to continue.", vbYesNo + vbCritical +
vbDefaultButton2, "Main Capture")
If confirmX = vbYes Then
Exit Sub
End If
Else
Selection.TypeText Answer & vbCrLf
ScreenCapture
Selection.Paste
Selection.InsertBreak Type:=wdPageBreak
End If
Loop
I'm writing a macro to read input from the operator and write the response
to a word document then capture a window from another application like MatLab
and past e that to the same document and repeat this process until the
operator exits by entering X. Everything works with exception of being able
to capture the desired screen. Right now I capture the inputbox screen
because it is the active window. Is there a way to select another window to
become the active window? Also, is there a way to list all the windows that
are open regardless of what application they are associated with. For example
if there is an Explorer, Word, Excel, and Powerpoint windows open can I
identify how many are open and select the one that match a title or
applicaiton? Thank you in advance for your assistance. Following is the
code I'm using.
Option Explicit
Public Declare Sub keybd_event Lib "user32" (ByVal bvk As Byte, ByVal _
bScan As Byte, ByVal dwflags As Long, ByVal dwExtrainfo As Long)
Public Const KEYEVENTF_KEYUP = &H2
Public Const VK_SNAPSHOT = &H2C
Public Const VK_MENU = &H12
Sub ScreenCapture()
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
Do
ansrlen = 0
Answer = InputBox("Enter color and associated number and then " & vbCr & _
"click ""Ok"" ONLY when you are ready to" & vbCr & _
"capture the screen" & vbCr & vbCr & _
"Enter X or x to exit.", "Main Capture")
ansrlen = Len(Answer)
Answer = UCase(Mid(Answer, 1, 1)) & Mid(Answer, 2, ansrlen)
If Answer = "X" Then
confirmX = MsgBox("Select ""Yes"" to confirm termination" & vbCr &
vbCr & _
"Select ""No"" to continue.", vbYesNo + vbCritical +
vbDefaultButton2, "Main Capture")
If confirmX = vbYes Then
Exit Sub
End If
Else
Selection.TypeText Answer & vbCrLf
ScreenCapture
Selection.Paste
Selection.InsertBreak Type:=wdPageBreak
End If
Loop