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?
Re: How to bind Microsoft Word document to a VB form
you could try the setparent API
else use an OLE control
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
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
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete