Yeah, yeah I know this is macrumors, but the standard vb forums aren't helping with this one.
OK, Here is the deal. I am calling Spell check from MS Word 2003 programmatically already, and it works great. My problem is that after spell check is complete you get this OK spell check is complete window. My problem is this pops up several times and it gets annoying. I want to press the button programmatically, but I having problems.
I have used FindWindow to get the window, but I am having trouble to know what effect I should use to "Press the button actually". I am running Spy++, but it I can not even sure how what to do. I'll post What I have so far. Am I barking up the right tree? So I have tried WM_CLOSE and WM_DESTORY, whatever BM event that Spy++ caught. Nothing has worked.
OK, Here is the deal. I am calling Spell check from MS Word 2003 programmatically already, and it works great. My problem is that after spell check is complete you get this OK spell check is complete window. My problem is this pops up several times and it gets annoying. I want to press the button programmatically, but I having problems.
I have used FindWindow to get the window, but I am having trouble to know what effect I should use to "Press the button actually". I am running Spy++, but it I can not even sure how what to do. I'll post What I have so far. Am I barking up the right tree? So I have tried WM_CLOSE and WM_DESTORY, whatever BM event that Spy++ caught. Nothing has worked.
Code:
Public Class Form1
Private Const WM_QUIT As Integer = &H12
Private Const WM_GETDLGCODE As Integer = &H87
Private Const BM_SETSTATE As Integer = &HF3
Private Const WM_DESTROY As Integer = &H2
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Short, ByVal lParam As Integer) As Integer
Private Declare Auto Function FindWindow Lib "user32" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As IntPtr
Private Declare Auto Function GetWindowText Lib "user32" ( _
ByVal hwnd As IntPtr, _
ByVal lpString As String, _
ByVal cch As Integer) As Integer
Private Const lpClassName = "Microsoft Office Word"
Private Function GetOK() As String
Dim hwnd As IntPtr = FindWindow(vbNullString, lpClassName)
Dim lpText As String = ""
If hwnd.Equals(IntPtr.Zero) Then
MsgBox("not running")
Return "Not running"
Else
MsgBox("running")
SendMessage(hwnd, WM_DESTROY, 0, 0)
Return "running"
End If
Return ""
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
GetOK()
End Sub
End Class