none
IRibbonUI.Invalidate() makes half the document disappear in Word 2007 RRS feed

  • Question

  • Hi all;

    Ok, this is a really weird one. On an Application.WindowSelectionChange event, if we call IRibbonUI.Invalidate() on the ribbon - then in Word 2007, for one document only, Word flashes as it redraws everything and the document is blank from the middle down.

    If I click reveal/hide formatting codes (to force a redraw), then everything is there as expected.

    Any idea what is going on and how we can avoid this issue?

    thanks - dave


    Who will win The International Collegiate Programming Championships?

    Monday, May 7, 2012 10:36 PM

Answers

  • Hi Dave

    <<It occurs on 3 machines we've tested on - Word 2007 only, this one document only. And the document is not corrupted, it is just that the bottom half of the page is not rendered. If you do anything in that part, it acts as though the text is there and any re-render shows it all.>>

    Mmm. In that case, I'd suspect a character symbol in the text that Word has trouble dealing with. Have you cracked open the document.xml file in the Package and taken a look around that particular spot?


    Cindy Meister, VSTO/Word MVP

    Sunday, May 13, 2012 8:25 AM
    Moderator

All replies

  • Hi DavidThi808,

    Thanks for posting in the MSDN Forum.

    Would your please show your scenario to call IRibbonUI.Invalidate in Application.WindowSectionChange event? As usual, IRibbonUI is a private private property of Ribbon class. Show me some snippet to explain it will make more sense.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, May 8, 2012 9:00 AM
    Moderator
  • Hi Tom;

    Here you go - this is my Ribbon code:

    		public void OnLoad(IRibbonUI ribbonUI)
    		{
    			ribbon = ribbonUI;
    		}
    
    		public override bool UpdateMenu()
    		{
    			try
    			{
    				if (ribbon == null)
    					return false;
    				ribbon.Invalidate();
    				return true;
    			}
    			catch (Exception)
    			{
    				return false;
    			}
    		}

    And this is my selection changed code:

    		private void Word_MainMenuOnUpdate(Word.Selection Sel)
    		{
    			menu.UpdateMenu();
    		}
    

    And this error occurs only with Word 2007 and only with a single Word document.

    thanks - dave


    Who will win The International Collegiate Programming Championships?

    Tuesday, May 8, 2012 2:33 PM
  • Hi DavidThi808,

    I noticed that there no MainMenuOnUpdate event in the World PIA. Would you please clarify it?

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, May 10, 2012 7:08 AM
    Moderator
  • Sorry, forgot a line of text:

    // nativeWordApp is an Application object
    Word.ApplicationEvents2_Event aee = (Word.ApplicationEvents2_Event)nativeWordApp;
    aee.WindowSelectionChange += Word_MainMenuOnUpdate;
    


    Who will win The International Collegiate Programming Championships?

    Thursday, May 10, 2012 1:07 PM
  • Hi Dave

    It's very difficult to track down something that's happening on only one document... Does this happen with the same document on every installation this is tried on? Or only some installations?

    Does this document contain anything "special" (such as a certain graphic not in any other document, lots of graphics, lots of tables - that kind of thing).

    Have you tried the usual ways of "rescuing" a damaged (corrupt) document to see if that solves the problem?


    Cindy Meister, VSTO/Word MVP

    Thursday, May 10, 2012 1:29 PM
    Moderator
  • Hi Cindy;

    I asked in case it was a known issue. If unknown then I think there's not much hope for this case.

    It occurs on 3 machines we've tested on - Word 2007 only, this one document only. And the document is not corrupted, it is just that the bottom half of the page is not rendered. If you do anything in that part, it acts as though the text is there and any re-render shows it all.

    thanks - dave


    Who will win The International Collegiate Programming Championships?

    Thursday, May 10, 2012 1:33 PM
  • Hi Dave

    <<It occurs on 3 machines we've tested on - Word 2007 only, this one document only. And the document is not corrupted, it is just that the bottom half of the page is not rendered. If you do anything in that part, it acts as though the text is there and any re-render shows it all.>>

    Mmm. In that case, I'd suspect a character symbol in the text that Word has trouble dealing with. Have you cracked open the document.xml file in the Package and taken a look around that particular spot?


    Cindy Meister, VSTO/Word MVP

    Sunday, May 13, 2012 8:25 AM
    Moderator