none
how to disable .doc/xls file Rribbon and backstate when they are opened with office 2010 RRS feed

  • Question

  • Hi all,

    I'd like to disable the backstage, no matter the file is .doc or docx. I use following code to disable .docx file successfully, However, it throws exception opening .doc file? is it possible to disable the backstage and ribbon of .doc file?

    using (WordprocessingDocument wpd = WordprocessingDocument.Open(@".\test.doc", true))
                {
                    CreateRibbon(wpd);
                }
     private bool CreateRibbon(WordprocessingDocument WDP)
            {
                bool result = false;
                MainDocumentPart MDP = WDP.MainDocumentPart;
                try
                {
                    RibbonExtensibilityPart REP = WDP.AddRibbonExtensibilityPart();
    		string xml = "<customUI xmlns=\"http://schemas.microsoft.com/office/2009/07/customui\">"
     			+ "<backstage>"
                      		+ "<tab idMso =\"TabNew\" visible =\"false\"></tab>"
    			+ "</backstage>"
    		+"</customUI>";
          		REP.CustomUI = new CustomUI(xml);
          		MDP.Document.Save();
          		result = true;
    		}
    		catch (Exception ex)
    		{		System.Diagnostics.Trace.TraceInformation(ex.Message);
    		return false;
    		}

    Best Regards

    After Base

    Sunday, December 30, 2012 12:03 PM

Answers

  • Hi after_base

    A *.doc file cannot have a "Backstage", nor can you modify or work with a *.doc file using the Open XML SDK. A *.doc file is in the old, proprietary, binary file format that was replaced in Office 2007 with Office Open XML.


    Cindy Meister, VSTO/Word MVP, my blog

    Sunday, December 30, 2012 3:44 PM
    Moderator