none
Word 2016 Ribbon becomes unresponsive after C# app does mail merge RRS feed

  • Question

  • I have a C# App that uses Office automation to merge data from a comma-delimited file into a Word document. Since Office 2016 was installed, after Word merges the "Ribbon" at the top becomes unresponsive. If I resize the Window(click restore the maximize) the ribbon works again. (I have tried doing the same thing in my app to no avail.) This problem is all over the Internet. Does anyone know if there is a Microsoft fix for this? It does not happen on all PC's.

    Code:

    object fileName2 = DA1_FileName_Local;
    object fileName_DOT = "Normal.dotm";
    object miss = Type.Missing;
    object pause = 5;
    object SaveIt = false;
    Microsoft.Office.Interop.Word._Application oWord;
    Microsoft.Office.Interop.Word._Document oDoc;
    oWord = new Microsoft.Office.Interop.Word.Application();
    MailMerge mer = null;
    Document MergeDoc = null;

    MergeDoc = oWord.Documents.Open(ref obj_fileName, ref 
        miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref 
        miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
    mer = MergeDoc.MailMerge;

    mer.OpenDataSource(DA1_FileName_Local, ref 
        miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref 
        miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);

    mer.Destination = WdMailMergeDestination.wdSendToNewDocument;
    object objPause = 5;
    mer.Execute(ref objPause);
    oWord.Visible = true;
    oWord.WindowState = WdWindowState.wdWindowStateMaximize;
    Thursday, September 28, 2017 6:56 PM

All replies

  • Hi,

    Since the issue is related to the C# code for Word features, I will help you move the thread to Word for developers forum for more help.

    People there are more familiar with codes and they can give more suggestion on it. Thanks for your understanding.

    Best Regards,
    Winnie Liang


    Please remember to mark the replies as answers if they help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, September 29, 2017 5:55 AM
  • Hi kentemon,

    Could you share us all the related files like DA1_FileName_Local and "Normal.dotm"? Then, we could make a test to reproduce your issue.

    I assume the Word 2016 Ribbon is blocked, I suggest you start a new thread to use Office Automation.

    using System.Threading;
    new Thread(() => 
    {     
        /* run your office automation code here */ 
        Console.WriteLine("Hello, world"); 
    }).Start();

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 2, 2017 2:18 AM
  • Thanks Winnie. How to I get to the, "Word for developers forum ?"

    Monday, October 2, 2017 4:43 PM
  • Hi Edward. How do I share files? Forgive me I am new to this site.
    Monday, October 2, 2017 4:49 PM
  • How to I locate the, "Word for developers forum?"
    Monday, October 2, 2017 4:51 PM
  • Hi kentemon,

    Your thread is in Word for Developers forum.

    >> How do I share files?

    You could upload files through OneDrive and then share us link here.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 5, 2017 7:07 AM
  • Hi Edward. Attached link has files(normal.dotm and cs32.da1) files requested. The .da1 file is the data source for the Word mail-merge document. It is a comma-delimited file where the first line contains the mere fields names and 2nd line contains the associated data.

    Hope this helps.Mail merge files

    Friday, October 6, 2017 1:59 PM
  • Hi kentemon,

    Could you check whether the files have uploaded correctly?

    After open your url, it is empty in OneDrive.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 9, 2017 2:08 AM
  • Hi Edward. When I click on the link, the files appear. Not sure what I've done wrong. Is there an email I can send these to as an attachment? Would that work?
    Tuesday, October 10, 2017 3:52 PM
  • Hi kentemon,

    You could send to me, I will help you to share through OneDrive.

    tonyhelp@outlook.com

    Update:

    Here are the files fro kentenmon.

    https://1drv.ms/f/s!AkFdZJAe27bbdiFvJAVQmn-B41I.

    Here is the code from kentemon.

    object fileName2 = DA1_FileName_Local;
    
    object fileName_DOT = "Normal.dotm";
    
    object miss = Type.Missing;
    
    object pause = 5;
    
    object SaveIt = false;
    
    Microsoft.Office.Interop.Word._Application oWord;
    
    Microsoft.Office.Interop.Word._Document oDoc;
    
    oWord = new Microsoft.Office.Interop.Word.Application();
    
    MailMerge mer = null;
    
    Document MergeDoc = null;
    
     
    
    MergeDoc = oWord.Documents.Open(ref obj_fileName, ref
    
    miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref
    
    miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
    
    mer = MergeDoc.MailMerge;
    
     
    
    mer.OpenDataSource(DA1_FileName_Local, ref
    
    miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref
    
    miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
    
     
    
    mer.Destination = WdMailMergeDestination.wdSendToNewDocument;
    
    object objPause = 5;
    
    mer.Execute(ref objPause);
    
    oWord.Visible = true;
    
    oWord.WindowState = WdWindowState.wdWindowStateMaximize;
     
    MergeDoc.Activate();                     <ç=================================NEW
    object objSaveChanges = false;
    MergeDoc.Close(ref SaveIt, ref miss, ref miss);

    Regards,

    Tony


    Help each other


    • Edited by Tony---- Thursday, October 12, 2017 5:40 AM
    Wednesday, October 11, 2017 3:14 AM
  • Hi kentemon,

    I made a test with your code and file under Word 2016 MSO (16.0.8201.2193) 64 bit in a Console Application, but I fail to reproduce your issue.

    Based on your description, it does not happen on all PC’s, I suggest you check the versions on the worked and no-worked PC’s to see whether it is related with Word version.

    In addition, I tried ScreenUpdating and ScreenRefresh, I suggest you check whether below code will work.

    Microsoft.Office.Interop.Word._Application oWord;
                Microsoft.Office.Interop.Word._Document oDoc;
                oWord = new Microsoft.Office.Interop.Word.Application();
                oWord.ScreenUpdating = false;
                MailMerge mer = null;
                Document MergeDoc = null;
                MergeDoc = oWord.Documents.Open(ref obj_fileName, ref
                miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref
                miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
                mer = MergeDoc.MailMerge;
                mer.OpenDataSource(DA1_FileName_Local, ref
                miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref
                miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
                mer.Destination = WdMailMergeDestination.wdSendToNewDocument;
                object objPause = 5;
                mer.Execute(ref objPause);
                oWord.Visible = true;
                object objSaveChanges = false;
                MergeDoc.Close(ref SaveIt, ref miss, ref miss);
                oWord.ScreenUpdating = true;
                oWord.ScreenRefresh();

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 12, 2017 5:58 AM
  • Hi Edward, just getting back to this. I will try the screenupdating and screenrefresh.

    Thank you.

    Wednesday, October 18, 2017 5:15 PM
  • Hi kentemon,

    If you have any update about this issue, please feel free to let us know.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, October 20, 2017 2:39 AM
  • Hi Edward.

    The target Word version is 2016. I implemented the code you provided and the problem still persists. I did my test on a Windows 10 PC with Word 2016. This issue did not arise until Word 2016. In the previous version of the app(written in VB6) I was able to resolve it my minimizing and maximizing Word in the code(with Word 2010 and 2016). This does not work with the C# version.

    Also, it seems to be intermittent. A colleague of mine said it did it occasionally, then started doing it all the time with no code change. I am wondering if this is a bug in Word 2016.

    Thanks for your attentin to this matter though.

    Kent


    Friday, October 20, 2017 1:08 PM
  • Hi kentemon,

    What is the specific Word Version?

    As my above reply, I fail to reproduce this issue under Word 2016 MSO (16.0.8201.2193) 64 bit. Could you try to update your Word to latest version?

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 23, 2017 6:45 AM
  • Hi Edward.

    W10 PC it IS happening on is: Word 2016 MSO 16.0.4266.1001 32 bit

    My W7 PC that is NOT happening on is: Word 2016 MSO 16.0.4549.1000 32 bit

    I will try to upgrade to latest version but will need to work with our Network people on this.

    I will let you know.

    Monday, October 23, 2017 3:35 PM
  • Edward - 

    Do you know what build# is for latest version of Word 2016 32-bit?

    Monday, October 23, 2017 3:52 PM
  • Hi kentemon,

    I suggest you try below link to install KB.

    # Office Updates

    https://support.office.com/en-us/article/Office-Updates-a118ec61-f007-492f-bfa5-5a6f764d5471

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 24, 2017 3:24 AM