none
Using WindowActivate event in word 2007 RRS feed

  • Question

  • Hi,

    I have written a code in WindowActivate event in word 2007 Addin to hide/show  ribbon tab.

    If i open two documents in word and when i switch between them the above mentioned concept works fine but when i debug the

    WindowActivate event is running multiple times?

    Can any one help me!

    Monday, September 23, 2013 7:35 AM

Answers

  • Hi Parthasarathy,

    WindowActivate event Occurs when document window is activated.

    If we debug this event, since the active window will be switched between the opened document and Visual Studio, so the document will be activated multiple times, so the event is occurred multiple times.

    For example, I wrote the code below in WindowActivate event:

    private void Application_WindowActivate(Word.Document Doc, Word.Window Wn)
            {
                MessageBox.Show("WindowActivate");
            }
    While debugging and the Word document openning, the WindowActivate event will be triggered. After the event goes over, the Word document will be activated again and the WindowActivate event will be triggered again.

    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, September 24, 2013 2:49 PM
    Moderator

All replies

  • Hi Parthasarathy,

    WindowActivate event Occurs when document window is activated.

    If we debug this event, since the active window will be switched between the opened document and Visual Studio, so the document will be activated multiple times, so the event is occurred multiple times.

    For example, I wrote the code below in WindowActivate event:

    private void Application_WindowActivate(Word.Document Doc, Word.Window Wn)
            {
                MessageBox.Show("WindowActivate");
            }
    While debugging and the Word document openning, the WindowActivate event will be triggered. After the event goes over, the Word document will be activated again and the WindowActivate event will be triggered again.

    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, September 24, 2013 2:49 PM
    Moderator
  • Thanks for your reply!

    This is my guess too.

    Wednesday, September 25, 2013 9:30 AM
  • Hi, 

    How you are able to hide/show the ribbon tab. Can you please help me. was trying to hide the backstage view in powerpoint add in in windows deactivate event. but couldn't find a solution yet.

    Wednesday, June 8, 2016 4:36 AM