Hello Hayrob,
Thanks for providing the additional information about your issue. Here are
some additional troubleshooting steps:
1. Try creating a new blank form and show it as a test, instead of showing
your ConfirmFinalSaveForm form. The code for your menu button handler would
simply be:
Dim frm As New Form1
frm.Show
2. Same as #1 above, but try ShowDialog instead of Show.
Question: Do either of the above show the form on top of the Word window,
or does the form still show behind the Word window?
3. You wrote "I have a top level form which instantiates the Word
application. When my program runs, this form is on top of the form I create
in Word."
As a test, what happens if you just manually start Word by clicking Start,
Programs, Microsoft Office, Microsoft Office Word 2003. Then click File,
Open in Word to open your managed document (.doc) file? When you then
click the menu button handler to run the simple code above to show Form1,
does the form show on top of the Word window or does it still show behind
the Word window?
4. If the above steps do not lead to determining a more specific
resolution, you may want to try using the Activate method of the form to
see if that will force focus to it. To start with, I suggest you use a
Timer in the form to wait a few seconds after the form is shown, then the
Tick event will call the Activate method of the form. Here are the steps
to try this in the Form1:
a. Using the Toolbox, add a Timer control to Form1.
b. Double-click the Timer1 control added to Form1. The Timer1_Tick event
procedure is created.
c. Use the following code for the Form_Load and the Timer1_Tick:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Timer1.Interval = 3000 '3 second interval
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Timer1.Stop()
Me.Activate()
End Sub
d. Now rebuild and run. Once Form1 is shown (by the menu button handler)
wait about 3 seconds and the Tick event will try to force the form into
focus via calling Activate.
The reason for the timer is to rule out any specific Form event for calling
Activate. The idea is to make sure calling Activate works when the form is
fully shown and ready. If calling Activate works in this case, then for a
more permanent solution you can try calling Activate from some other event,
like the Form Load event.
For information and sample code for integrating Office with Visual Basic,
Visual C++, Internet Scripts, and other programming languages, please see
http://msdn.microsoft.com/library/techart/VSOfficeDev.htm. This site
contains the most up-to-date information for using developer tools for
Office integration and extensibility.
Best regards,
Greg Ellison
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Are you secure? Please visit the Microsoft Security & Privacy Center
(
http://www.microsoft.com/security) for the latest news on security updates.
--------------------