How to bind Microsoft Word document to a VB form
Hello everybody,
I would like to start MS word from VB and have the window displayed within a form. At the moment, when I start MS word from VB, it simply opens up in its own window, separate from the VB environment. This is not what I want at all. Who can help solve this challenge?
Thanks.
Re: How to bind Microsoft Word document to a VB form
you could try the setparent API
else use an OLE control
1 Attachment(s)
Re: How to bind Microsoft Word document to a VB form
Thank you Sir. Apology for the long silence. I have been struggling to get more information on the SetParent(...) function. After so many hours on Google, I was able to find a code snippet that could open a Word document and display the window inside a PictureBox control, for instance (see attached image). However, there is still an issue that I would like to resolve. As shown by the red arrow, when a user clicks on the Windows button and opens a new Word document, the VB application loses control of the new window. What I would like to see is that the new window be displayed inside another PictureBox control.
Here some of the things that I would like to know:
1. Is the new window a child of the existing window or is the new window a parent window in its own right?
2. The VB code uses the SendMessage(...) function to send messages to Windows. How do I get Windows to send messages to the VB code? E.g. how do I get Windows to send a message to VB when a new window is opened?
3. How can I disable the Open... command on an existing window such that a user cannot open a new window from it?
4. Where can I get documentation on how to use VB to interact with Windows?
And to all forum members, please be kind enough to oblige me with your helpful contributions.
Re: How to bind Microsoft Word document to a VB form
Quote:
What I would like to see is that the new window be displayed inside another PictureBox control.
you could use a timer to poll for additional instances of Word, then setparent to get it into a picturebox
or
try Word events to see if they detect the opening of a new window
Re: How to bind Microsoft Word document to a VB form
Thank you Sir. I have been working on the code. I have had to go to Vb.Net forum in order not to duplicate my posts. Please, see http://www.vbforums.com/showthread.p...05#post4406505
I will appreciate it if you could check out the posts and see what's missing.