none
Has the OpenDataSource method in the Word Document MailMerge object gone away in Word 2013? RRS feed

  • Question

  • Our application interfaces to Word and does a mail merge via C# developed in Visual Studio 2010.  We have been doing this since the dawn of time using the following code:

    oMasterDoc = oWord.Documents.Open(ref oMaster, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

    oMerge = oMasterDoc.MailMerge;

    oMerge.OpenDataSource((string) oData, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, 
    ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

    where oMaster is the full path of a document to have the data merged into, and oData is the full path of a CSV file that is the data source.

    This has worked beautifully in all versions of Word, including 2003, 2007, and 2010.  However, in Word 2013 we get a "System.Runtime.InteropServices.COMException", with a message

    "The OpenDataSource2000 method or property is not available because this command is not available for reading."

    What can I do to get around this?

    mdpowers

    Tuesday, March 5, 2013 10:06 PM

Answers

  • I’ve had the same problem with Word 2013 that methods used since the dawn of time now returns the error “method or property is not available because this command is not available for reading”

    I discovered that Word 2013 has a new default when documents are opened and documents are initially set to reading mode which do not accept my commands.

    Changing the view of the document before applying further commands did the trick for me.

    I’m not familiar with C#, but here is the line I added in Visual Basic to change the view to allow editing.

    Doc.ActiveWindow.View.Type = wdNormalView

    Doc is the document object of the document opened.

    Hope this helps.

    • Marked as answer by mdpowers-slo Wednesday, March 6, 2013 5:36 PM
    Wednesday, March 6, 2013 7:47 AM

All replies

  • I’ve had the same problem with Word 2013 that methods used since the dawn of time now returns the error “method or property is not available because this command is not available for reading”

    I discovered that Word 2013 has a new default when documents are opened and documents are initially set to reading mode which do not accept my commands.

    Changing the view of the document before applying further commands did the trick for me.

    I’m not familiar with C#, but here is the line I added in Visual Basic to change the view to allow editing.

    Doc.ActiveWindow.View.Type = wdNormalView

    Doc is the document object of the document opened.

    Hope this helps.

    • Marked as answer by mdpowers-slo Wednesday, March 6, 2013 5:36 PM
    Wednesday, March 6, 2013 7:47 AM
  • Thanks muchly Leidulf!  That did the trick.

    mdpowers

    Wednesday, March 6, 2013 5:36 PM
  • Thanks Leidulf Alnes, adding this line helped me too. Do you know any article published from Microsoft regarding the same change in behavior?
    Monday, June 24, 2013 8:10 AM
  • Thank you:-)
    It was impossible to figure out that this was the problem without your help
    Monday, August 5, 2013 1:06 AM
  • Another workaround if a user can't change the code they're relying on is to change the Option for this in Word Options. Specifically, disable the "Open e-mail attachments and other uneditable files in reading view" available on the General tab
    • Proposed as answer by Dan Wilkins Monday, August 19, 2013 1:33 AM
    • Unproposed as answer by mdpowers-slo Monday, August 19, 2013 2:47 AM
    Monday, August 19, 2013 1:31 AM
  • In our case, this would not work; we are not able to control the settings in thousands of user's Word.  It was very easy to change the code.  We only change the view mode if the user has Word 2013, and for us it works very well.


    mdpowers

    Monday, August 19, 2013 2:50 AM
  • Actually, if this is a networked setup, you should be able to control the setting via a GroupPolicy on the Registry. Place to ask about that would be the TechNet forums where network administration is supported.

    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, August 21, 2013 11:21 AM
    Moderator
  • In our case, we do not control  the networks of our users, and in fact we have a number of users who are not even on a network.  For us, it was easy to change the call into Word from our software.

    In cases where the call into Word was from software that the users did not control, the suggestion given above would be very viable.  

    However for the specific question I posed, changing our software to set the view type when the user has Word 2013 was the easiest solution. 


    mdpowers

    Wednesday, August 21, 2013 12:17 PM
  • thanks Sir Dan! Worked for me :-)
    Tuesday, November 19, 2013 5:54 PM