Hello
I'm trying to open MSWord from a VB maximised form and ensure that the MSWord window is always on top of the maximised form. The following code doesn't work :-(
I don't get any errors, but if click on the main maximised form the MSWord window doesn't stay put.
Any suggestions much appreciated....
Kate
Private Sub Command1_Click()
Dim retval
retval = Shell("C:\Program Files\Microsoft Office\Office\winword.exe", vbNormalFocus)
If retval = 0 Then
MsgBox "error on Shell command"
else
AppHWnd= GetActiveWindow()
If AppHWnd= 0 Then
MsgBox "Error on GetActiveWindow"
end if
end if
End Sub
Private Sub Form_Click()
Dim flags As Long
Dim retval As Long
flags = &H1 Or &H20
'neither of the following lines seem to work!
'retval = BringWindowToTop(AppHWnd)
'retval = SetWindowPos(AppHWnd, 0, 0, 0, 0, 0, flags)
If retval = 0 Then MsgBox "Error"
End Sub
I'm trying to open MSWord from a VB maximised form and ensure that the MSWord window is always on top of the maximised form. The following code doesn't work :-(
I don't get any errors, but if click on the main maximised form the MSWord window doesn't stay put.
Any suggestions much appreciated....
Kate
Private Sub Command1_Click()
Dim retval
retval = Shell("C:\Program Files\Microsoft Office\Office\winword.exe", vbNormalFocus)
If retval = 0 Then
MsgBox "error on Shell command"
else
AppHWnd= GetActiveWindow()
If AppHWnd= 0 Then
MsgBox "Error on GetActiveWindow"
end if
end if
End Sub
Private Sub Form_Click()
Dim flags As Long
Dim retval As Long
flags = &H1 Or &H20
'neither of the following lines seem to work!
'retval = BringWindowToTop(AppHWnd)
'retval = SetWindowPos(AppHWnd, 0, 0, 0, 0, 0, flags)
If retval = 0 Then MsgBox "Error"
End Sub