none
Handling a workbook with password RRS feed

  • Question

  • Hi, and thanks in advance for any help.

    Sometime ago I created an add-in in excel 2007 with a ribbon and some excel functions, with visual 2008. It works fine. Now, the workbooks will have a password, which I know, and it will be the same for every workbook.

    What i'm trying to do it's that in the computers where the add-in it's installed, the add-in passes the password, so that the users don't know it's a password in the workbook when they open it. They will know the workbook has a password if they try to open the workbook on a computer without the add-in installed.

    I tried the workbook_open event, but the password inputbox displays before the workbook_open event, so it doesn't allow me to do what i'm thinking. I still haven't found neither an event displayed before the password input box, nor the way to capture the event generated when the password it's displayed. Suggestions?


    Wednesday, April 27, 2011 5:41 PM

Answers

  • You can find an easy example here: http://msdn.microsoft.com/en-us/library/bb421511%28en-us%29.aspx

    It's basically just adding an additional tag in u'r ribbon.xml called something like:

    ...
            <group id="grpYourGroup"
                   getLabel="Group_GetSomeTranslation"
                   getVisible="Group_GetVisible">
    ...

    and create a method that returns bool true/false depending on u'r password processing.

            public bool Group_GetVisible(IRibbonControl control)
            {
                if(something == something)
               {
                     return true;
               } else {
                    return false;
               }
            }

    Using invalidate can do this dynamically.


    Andreas M.
    Friday, April 29, 2011 6:30 PM

All replies

  • Hi Hernancho007,

    The way I've dealt with this is to have a custom Ribbon button in my add-in that the user must click to open the protected Workbook. The ribbon callback performs the open and supplies the password.

    Hope this helps


    Regards, Rich
    Wednesday, April 27, 2011 6:46 PM
  • There also the possibility of using the getVisible attribute of a group, tab, button etc in a ribbon in where you can return true/false depending on password input/processing.

    Andreas M.
    Thursday, April 28, 2011 3:28 PM
  • Andreas,

    Can you say more about that, how would that work? I may have a need for something like that.

    Thanks


    Regards, Rich
    Thursday, April 28, 2011 4:07 PM
  • You can find an easy example here: http://msdn.microsoft.com/en-us/library/bb421511%28en-us%29.aspx

    It's basically just adding an additional tag in u'r ribbon.xml called something like:

    ...
            <group id="grpYourGroup"
                   getLabel="Group_GetSomeTranslation"
                   getVisible="Group_GetVisible">
    ...

    and create a method that returns bool true/false depending on u'r password processing.

            public bool Group_GetVisible(IRibbonControl control)
            {
                if(something == something)
               {
                     return true;
               } else {
                    return false;
               }
            }

    Using invalidate can do this dynamically.


    Andreas M.
    Friday, April 29, 2011 6:30 PM