none
Title bar of Word automation in vb.net not displaying properly RRS feed

  • Question

  • I am automating a mail merge inside a vb.net application (VS2008).   This is working ok except that the title bar of the Word application is cut off a little, and it sometimes gets covered up.   In order to display the Word application inside my VB.net application I am using SetParent to assign to a groupbox named Frame1.

    Private oappWord As New Microsoft.Office.Interop.Word.Application
    Private oDoc As Microsoft.Office.Interop.Word.Document
    
    oappWord.Caption = "myWord"
    oDoc = oappWord.Documents.Add(, , Microsoft.Office.Interop.Word.WdMailMergeMainDocType.wdFormLetters)
    lngDocHandle = FindWindow(vbNullString, oDoc.ActiveWindow.Caption & " - " & oappWord.Caption)
    oappWord.Caption = CStr(Nothing) 'set caption back
    
    oappWord.WindowState = Microsoft.Office.Interop.Word.WdWindowState.wdWindowStateMaximize
    SetParent(lngDocHandle, Frame1.Handle.ToInt32)
    
    oappWord.Visible = True

    What is happening is that the title bar of the Word application appears as so, with the save, undo, redo icons cut off.  I tried setting oappWord.top with no improvement:

    If I then click outside of my groupbox, and hover the mouse over the Word title bar, the Word title bar changes to, and even the min/max/close icons are covered:

    So while I can still access the File tab to save, the Save icon is covered up.   Then if I click on various Word tabs, the Title bar again is partially painted.

    I don't work with Word automation very much - this is just a feature of our application.   So I'm hoping someone out there can spot what I am doing wrong fairly easily.

    Thanks inadvance!


    • Edited by GreydogMe Sunday, August 19, 2018 1:05 AM
    Sunday, August 19, 2018 1:05 AM

Answers

  • Finally solved this by setting oappWord.width small enough.  Setting it to the size of the parent container did not work.  It had to be over 200 pixels smaller than the panel which was being set as the parent for the vertical scroll bar to appear on the right.   I could not get any horizontal scroll bar to appear with any of the options.   Hope it helps someone.

    Cindy - if you think this belongs in another forum, please feel free to move it.

    • Proposed as answer by Simon Wu-MSFT Monday, September 3, 2018 10:13 AM
    • Marked as answer by GreydogMe Monday, September 3, 2018 4:39 PM
    Monday, August 20, 2018 4:37 AM

All replies

  • This part is certainly the problem

    <<  In order to display the Word application inside my VB.net application I am using SetParent to assign to a groupbox named Frame1.>>

    You need to concentrate on how you can get it to display inside your application. For that, it might be better to move your question to a Visual Studio WinForms forum since this is not really a Word problem? Reply if you want a forum moderator to do so.


    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    Sunday, August 19, 2018 11:03 AM
    Moderator
  • I guess I was wondering if it was a property of the Word automation, or something that could be done with the title bar. 
    Sunday, August 19, 2018 5:42 PM
  • I have since discovered that if I change the oappWord.Windowstate from wdWindowStateMaximize, to wdWindowStateNormal, my save/undo/redo icons are now fully visible.   However, then I lose the scroll bars and the status bar on the document area.   And the ribbon bar is cut off on the right with no scroll bar.   

    I also changed the groupbox container to a panel instead with autoscroll set to true, but that didn't help.

    will keep playing trial and error with the options and hope someone knows what settings I need off the top of their head to get the document area so that it is scrollable and the status bar on the bottom with the view and zoom settings still visible.

    Thanks again.

    Monday, August 20, 2018 12:06 AM
  • Finally solved this by setting oappWord.width small enough.  Setting it to the size of the parent container did not work.  It had to be over 200 pixels smaller than the panel which was being set as the parent for the vertical scroll bar to appear on the right.   I could not get any horizontal scroll bar to appear with any of the options.   Hope it helps someone.

    Cindy - if you think this belongs in another forum, please feel free to move it.

    • Proposed as answer by Simon Wu-MSFT Monday, September 3, 2018 10:13 AM
    • Marked as answer by GreydogMe Monday, September 3, 2018 4:39 PM
    Monday, August 20, 2018 4:37 AM