G
Greg Oij
I have an application that displays a document on top of
another one after analyzing the origional one.
It is compatible with Word '97, Word 2000, Word XP, and,
with one small exception, Word 2003.
When the new document is displayed, it should be
displayed on top of the origional document. The new
document is always displayed on top of the origional in
Word '97, Word 2000, and Word XP, and about 60-80% of the
time in Word 2003.
The code that I've tried to remedy this problem is:
Windows("WindowCaptionName").Activate
Documents(DOCNUMBER).Activate
and
Documents(DOCNAME).Activate
I know that the "WindowCaptionName", DOCNUMBER, and
DOCNAME variables are correct through setting breakpoints.
When that didn't work 100% of the time (again, this
problem only occurs in Word 2003), I tried:
Declare Function GetActiveWindow Lib "user32" () as Long
Declare Function SetForegroundWindow Lib "user32" (ByVal
hwnd As Long) as Long
Dim lRetVal as Long, lHandle as Long
'Here, correct window is active but not always on top
lHandle = GetActiveWindow()
lRetVal = SetForegroundWindow(lHandle)
after, which didn't seem to make any difference.
Is there a VBA routine that will guarantee that the new
document is always displayed on top of the origional doc?
Thank you for any ideas that you might have.
another one after analyzing the origional one.
It is compatible with Word '97, Word 2000, Word XP, and,
with one small exception, Word 2003.
When the new document is displayed, it should be
displayed on top of the origional document. The new
document is always displayed on top of the origional in
Word '97, Word 2000, and Word XP, and about 60-80% of the
time in Word 2003.
The code that I've tried to remedy this problem is:
Windows("WindowCaptionName").Activate
Documents(DOCNUMBER).Activate
and
Documents(DOCNAME).Activate
I know that the "WindowCaptionName", DOCNUMBER, and
DOCNAME variables are correct through setting breakpoints.
When that didn't work 100% of the time (again, this
problem only occurs in Word 2003), I tried:
Declare Function GetActiveWindow Lib "user32" () as Long
Declare Function SetForegroundWindow Lib "user32" (ByVal
hwnd As Long) as Long
Dim lRetVal as Long, lHandle as Long
'Here, correct window is active but not always on top
lHandle = GetActiveWindow()
lRetVal = SetForegroundWindow(lHandle)
after, which didn't seem to make any difference.
Is there a VBA routine that will guarantee that the new
document is always displayed on top of the origional doc?
Thank you for any ideas that you might have.