none
Ribbon object is getting lost in Word 2013 but it was working fine 2007 RRS feed

  • Question

  • Hi

    We have an application which was working fine in Word 2007 which uses ribbon object as below

    thisRibbon.Invalidate

    where thisRibbon is declared as "Public thisRibbon As IRibbonUI"

    Public Sub InitializeRibbon(ribbon As IRibbonUI)
        Set thisRibbon = ribbon
    End Sub

    In Word 2013, thisribbon is coming as "Nothing" which is causing runtime error "91". However, it was coming " " (Blank) in word 2007 and working fine.

    Can you please suggest if anything has changed in Word 2013?

    Regards

    P


    • Edited by jain_p99 Wednesday, August 3, 2016 10:39 PM Added content
    Wednesday, August 3, 2016 10:36 PM

Answers

  • >>>I am not getting above error. Have you made any changes to the document and then you are getting above error? If not then you have to save both the documents in one folder (create new folder) and try.

    I have saved both the documents in one folder and made no changes to the document in Word 2013, I got above error, but not in Word 2007. I have searched over Office 2013 Help Files: Office Fluent User Interface Control Identifiers, I am not able to find any idmso is "FilePublish" and "WordOptionsDialog". There are user interface differences in Office 2013 and Office 2007.

    You could download Office 2013 Help Files: Office Fluent User Interface Control Identifiers to check.

    For more information, click here to refer about User interface differences in Office 2010 vs earlier versions

    Thanks for your understanding.
    • Proposed as answer by David_JunFeng Thursday, August 11, 2016 2:02 PM
    • Marked as answer by David_JunFeng Tuesday, August 16, 2016 2:01 PM
    Wednesday, August 10, 2016 2:08 AM

All replies

  • Hello,

    What ribbon XML markup did you use in the add-in?

    I'd suggest checking the XML namespace. Word 2007 and 2013 require different namespaces. Read more about the Fluent UI in the following series of articles:

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)


    [custom.development]

    Wednesday, August 3, 2016 10:47 PM
  • >>>In Word 2013, thisribbon is coming as "Nothing" which is causing runtime error "91". However, it was coming " " (Blank) in word 2007 and working fine.

    Can you please suggest if anything has changed in Word 2013?<<<

    According to your description, there is a common problem when you are working with the Ribbon with RibbonX and VBA. The ribbon object (which is initialized when Excel loads your file) can loose its reference to the ribbon, which means your code can no longer tell Excel to update your ribbon customizations. There is simply no easy built-in way to recover the handle to the Ribbon when there are problems in or with your code. The only way to fix it is to close reopen your workbook, not a very user friendly way.

    But MVP Rory Archibald came up with a great idea. The example in the workbook that you can download on this page is based on Rory's idea store the pointer to the IRibbonUI in a cell (or Name or wherever) then use CopyMemory to get it back when the state is lost.

    You can use this example workbook to test this method to recover the Ribbon handle if it is lost. 

    Download: Loss of Ribbon state.zip

    For more information, click here to refer about losing the state of the global IRibbonUI ribbon object

    Disclaimer: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Thursday, August 4, 2016 4:47 AM
  • Hi Eugene

    XML namespace looks same to me in both cases.

    Thursday, August 4, 2016 1:47 PM
  • Hi David

    I have Word document instead excel and I cannot save the ribbon reference on the current document as user will be updating it at run time. However, I can save the ribbon reference in registry.

    Background about the process:

    We have 2 templates, user need to open once template (DOCM file) to active the Ribbon on 2nd template (DOTM file). So that, user can open the 2nd template and work on it.

    The example you have provided, it is using "GetRibbon" which is not working in my case because ribbon reference will be saved when 2nd template will be open but GetRibbon is called in first template which is causing issue.

    Can you please suggest?

    • Edited by jain_p99 Thursday, August 4, 2016 2:42 PM Updated the contents
    Thursday, August 4, 2016 1:49 PM
  • Hi jain_p99,

    According to your description, could you upload your Word document file on OneDrive, then provide this link? It will help us reproduce and resolve your issue.

    Thanks for your understanding.

    Friday, August 5, 2016 1:26 AM
  • Hi David

    I have uploaded the documents on OneDrive. Please refer below link for the same. You need to open "DOCU1.docm" file first, it will add one ADD-INS menu in this document as well as in DOCU2.dotm file. However, when you open "DOCU1.docm" file you will get the run time error "91" which is the issue. If you press the end button on the run time error popup then it will add the required menu but I need to correct the runtime issue. Kindly note, this issue is not coming in Word 2007 and issue exists in Word 2013.

    https://onedrive.live.com/?id=9C1D491143703CE4!106&cid=9C1D491143703CE4

    Friday, August 5, 2016 9:03 AM
  • Hi jain_p99,

    Thanks for your sharing your document, I try to download documents by your providing link, unfortunately, I am not able. So please check your OneDrive link.

    Sorry for the inconvenience. 

    Thanks for your understanding.
    Monday, August 8, 2016 9:07 AM
  • Hi David

    Can you please try below link and let me know? Please save both the documents in one folder.

    https://1drv.ms/f/s!AuQ8cEMRSR2caqRrf7bGNcgz-EQ



    • Edited by jain_p99 Monday, August 8, 2016 7:44 PM content updated
    Monday, August 8, 2016 7:25 PM
  • Hi jain_p99,

    Thanks for your correting this link, I have downloaded two documents successfully, and reproduced this issue, but when I opened this DOCU1.docm, I alse got these errors:


    I am not able to find good solution to overcome this issue, this workaround is that you could create VSTO add-in.

    In addition if you have any feedback for Word, please feel free to submit them to User Voice:

    https://word.uservoice.com/

    Thanks for your understanding. 

    Tuesday, August 9, 2016 2:35 AM
  • Thanks David.

    I am not getting above error. Have you made any changes to the document and then you are getting above error? If not then you have to save both the documents in one folder (create new folder) and try.

    Tuesday, August 9, 2016 10:38 AM
  • >>>I am not getting above error. Have you made any changes to the document and then you are getting above error? If not then you have to save both the documents in one folder (create new folder) and try.

    I have saved both the documents in one folder and made no changes to the document in Word 2013, I got above error, but not in Word 2007. I have searched over Office 2013 Help Files: Office Fluent User Interface Control Identifiers, I am not able to find any idmso is "FilePublish" and "WordOptionsDialog". There are user interface differences in Office 2013 and Office 2007.

    You could download Office 2013 Help Files: Office Fluent User Interface Control Identifiers to check.

    For more information, click here to refer about User interface differences in Office 2010 vs earlier versions

    Thanks for your understanding.
    • Proposed as answer by David_JunFeng Thursday, August 11, 2016 2:02 PM
    • Marked as answer by David_JunFeng Tuesday, August 16, 2016 2:01 PM
    Wednesday, August 10, 2016 2:08 AM