Results 1 to 5 of 5

Thread: How to bind Microsoft Word document to a VB form

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2012
    Posts
    87

    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.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2012
    Posts
    87

    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.
    Attached Images Attached Images  

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2012
    Posts
    87

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width