none
Starting Word 2007 via OLE intermittently is missing both the Ribbon and the Menu RRS feed

  • Question

  • Our developed applications communicate with Microsoft Word via OLE. We will attach to a running version of Word (if one is available) or start Word up as a new process.  Once in a while, when our application starts a new instance of Word 2007, the menu bar and ribbon are missing as shown below.

    Again, this only occurs once in a while.  Usually, when our application starts a new instance of Word, everything begins as normal.  Here is the code block that I use to start Word 2007:

    try { wd = (Microsoft.Office.Interop.Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application"); } catch { try { wd = new Microsoft.Office.Interop.Word.Application( ); } catch (System.Exception ex) { Global.Global.ShowError(parent, "Error starting Word - " + ex.Message); wd = null; return false; }

    }

    Any ideas on how to prevent this, or ideas on how (via OLE) to show the Menu and Ribbon would be greatly appreciated.


    James M. Culpepper

    Monday, July 11, 2016 1:36 PM

Answers

  • Our IT department does not give developers enough privileges to install/uninstall applications, nor can we disable something they deem critical such as RESManager.  I appreciate your eagerness to pinpoint the cause of this issue.  However, from our standpoint, commenting out the line noted above has fixed our problem and we cannot commit more time on this. Thank you again for your assistance in finding a work around.

    James M. Culpepper

    Friday, July 15, 2016 11:29 AM

All replies

  • Hi Jim Culpepper,

    I try to test the code and find that the part of the code that you had mentioned above with that we are unable to reproduce the issue on our side.

    you had mentioned that this is occurs only once in a while.

    did you find any uncommon behavior or situation when this issue occurs.

    the other thing I want to ask you that what you are trying to achieve using OLE?

    is it related with ribbon?

    can provide some more information regarding that so that we can try to find the issue.

    Regards

    Deepak 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, July 12, 2016 5:55 AM
    Moderator
  • Our LOB applications communicate with MS Word to create documents, typically by opening an existing document, traversing the Bookmarks, and supplying data similar to a mail/merge.

    The problem we are seeing is intermittent and only occurs when Word 2007 is not already running.  It does not appear to be related to any particular portion of our application or any particular template document we are opening.

    Our solution, thus far, is to tell users to keep Word running on their workstation prior to using our LOB applications.


    James M. Culpepper

    Tuesday, July 12, 2016 11:01 AM
  • Hi Jim Culpepper,

    As I told you its looks like the above mentioned code block is just for an example.

    from that code block when we test we are not able to reproduce the issue.

    because you can also see that it is a simple statement written there if word is already running then get its object else start a new object and in between any error occurs then it will be catch and display it.

    the other question I want to ask you that this issue occurs with only Word 2007 or other version of Word also having this issue?

    if other version working correctly then it can be possible that it is some kind of bug in word 2007.

    so if it is a bug then we need to confirm it first then I can provide you a link to give information of bug to word user voice.

    so to confirm, can you able to share your code that can able to reproduce the issue? it is helpful to narrow down the issue.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, July 13, 2016 6:07 AM
    Moderator
  • I believe I have isolated the problem in preparing code to submit to you.  In the following Console application, the commented line beginning with "wd.ActiveWindow.WindowState = " seems to be what is causing the ribbon and menu to disappear.  Again, this only occurs when Word 2007 is not already running.  On my machine, the behavior of this Console app is consistent.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace TestWordOLE
    {
      class Program
      {
        static Microsoft.Office.Interop.Word.Application wd;
    
        static void Main(string[ ] args)
        {
          try
          {
            wd = (Microsoft.Office.Interop.Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
          }
          catch
          {
            try
            {
              wd = new Microsoft.Office.Interop.Word.Application( );
            }
            catch (System.Exception ex)
            {
              Console.WriteLine("Error starting Word - " + ex.Message);
              wd = null;
              return;
            }
          }
    
          Microsoft.Office.Interop.Word.Documents docs = (Microsoft.Office.Interop.Word.Documents)wd.Documents;
          Microsoft.Office.Interop.Word.Document thisDoc = docs.Add( );
          //wd.ActiveWindow.WindowState = Microsoft.Office.Interop.Word.WdWindowState.wdWindowStateNormal;
          thisDoc.Activate( );
    
          // further processing on the document.....
    
    
          wd.Visible = true;
          wd.ScreenUpdating = true;
          wd.WindowState = Microsoft.Office.Interop.Word.WdWindowState.wdWindowStateMaximize;
          wd.Activate( );
        }
      }
    }


    James M. Culpepper

    Wednesday, July 13, 2016 12:35 PM
  • Hi Jim Culpepper,

    I am trying to reproducing the issue with your above mentioned code.

    I will tell you the results as I will complete with word 2007.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 14, 2016 7:05 AM
    Moderator
  • Hi Jim Culpepper,

    I try to reproduce but still I did not get this behavior.

    I want to ask you did you installed any windows or office updates in recent days?

    other thing you can try to do is repair the Ms Office and again try to run.

    can you find this behavior on multiple machines? or just single machine have this issue?

    please let us know so that we can try to suggest you further.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 14, 2016 7:45 AM
    Moderator
  • It does occur on multiple machines.  However, I have commented out the line:

    //wd.ActiveWindow.WindowState = Microsoft.Office.Interop.Word.WdWindowState.wdWindowStateNormal;
          thisDoc.Activate( );

    and it now works as expected on all machines. 

    Our IT department distributes all Windows updates so I cannot attest to whether we have had any updates to Word 2007 recently.  I will mention that this behavior has been going on for quite some time.

    One other caveat is that our IT department has installed "RES Manager" (see Res.com) on all workstations as a security and workstation manager tool that interacts with Word and Excel.  Maybe it affects how Word starts up.

    Thank you for following up on this.


    James M. Culpepper

    Thursday, July 14, 2016 11:41 AM
  • Hi Jim Culpepper,

    you had mentioned that "RES Manager" is interacting with Word and Excel.

    I am not sure how it is interacting with Word and Excel and because of this software this kind of behavior occur in Word.

    but just for a confirmation regarding that can you please check to try to run this code with word after disabling this software for some time or it is more better that you can try to do a test after uninstalling this software.

    so that we can strongly decide regarding this software.

    Regards

    Deepak  

    ,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, July 15, 2016 8:46 AM
    Moderator
  • Our IT department does not give developers enough privileges to install/uninstall applications, nor can we disable something they deem critical such as RESManager.  I appreciate your eagerness to pinpoint the cause of this issue.  However, from our standpoint, commenting out the line noted above has fixed our problem and we cannot commit more time on this. Thank you again for your assistance in finding a work around.

    James M. Culpepper

    Friday, July 15, 2016 11:29 AM