T
TTD
Hello,
I need to close Word from Excel VBA. I have the code. But sometimes a user
has an open file in Word and during closing Word asks to save it. But when
Word is on the background and another application is in front of it, the
user doesn't see the questiondialog and Excel can't close Word.
I've found some code to get an application to the foreground, but It doesn't
seem to work.
' **************** Declare API Function *********************************
Declare Function SetForegroundWindow Lib "user32" Alias
"SetForegroundWindow" _
(ByVal hwnd as Long) as Long
' *************** Command to bring our Window to the foreground
**************
Public Sub SetForeground(hWnd as Long)
SetForegroundWindow hWnd
End Sub
Does anyone have any ideas?
Thanks for your time and attention.
I need to close Word from Excel VBA. I have the code. But sometimes a user
has an open file in Word and during closing Word asks to save it. But when
Word is on the background and another application is in front of it, the
user doesn't see the questiondialog and Excel can't close Word.
I've found some code to get an application to the foreground, but It doesn't
seem to work.
' **************** Declare API Function *********************************
Declare Function SetForegroundWindow Lib "user32" Alias
"SetForegroundWindow" _
(ByVal hwnd as Long) as Long
' *************** Command to bring our Window to the foreground
**************
Public Sub SetForeground(hWnd as Long)
SetForegroundWindow hWnd
End Sub
Does anyone have any ideas?
Thanks for your time and attention.