none
Document Level Customization - Excel RRS feed

  • Question

  • Hi,

    This is with reference to my previous thread....

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=585932&SiteID=1

    (Regarding the bug mentioned by Cindy in the replies, I got a confirmation from Microsoft VSTO Support regarding the bug you had mentioned. They have confirmed the bug and have sorted the same and would be working fine with the Beta2 Tr version which would be shipped out shortly.)

    A couple of questions regarding the above topic (document level customization)...

    1. Using the workbook level customization which is really a good suited option for me, I would like to add a usercontrol form on a CustomTaskPane. However, the CustomTaskPane is not available under the ThisWorkbook class. It appears only under This_Application class. Is there anyway I could use a CustomTaskPane instead of Action Pane.

    2. In ActionPane, can I change the its title (always shows Document Actions). Can I disable the Close button on the ActionPane, so that the actionpane is kept always visible.

    3. How do I set a toggleButton on the ribbon pressed or released based on the ActionPane visibility. (For example when load of the excel document, the actionpane is visible, I would like to set the toggleButton pressed. In case users close the actionpane, i would like to release the press of the toggleButton)

    Regards,

    Markand 

    Tuesday, August 8, 2006 5:53 AM

Answers

  • 1. Using CustomTaskPane from wokbook level customization will be possible, but not with the current VSTO v3 CTP. Your workbook customization will need to communicate with the add-in. It will need to get an access to addin's automation object using Application.COMAddin[<AddinName>].Object. The problem is that latest CTP can not initialize the COMAddin.Object property correctly, but this will be possible in the future. Also, I think you will run into problem when your workbook solution will affect global UI which will show in other workbooks as well. So, I think ActionsPane is the preferred solution for workbook level customization, but again I do not know your application requirement well.

    2. You can not change the title of the ActionsPane or disable the close button. The UI guidelines about TaskPanes in Office is that it should be an inobtrusive way of providing additional information to the user. Not something that will be stuch in your face all the time.

    3. I think the toggleButton question has also been answered on internal aliases. Here is the result:

    Subject: RE: Custom ribbon toggle button--how to set toggle state programatically...

     

    1. specify in your ribbon markup that the enabled state of the button is dynamic, eg:

     

    getPressed="OnGetPressed"

     

    1. Provide a matching callback, eg:

     

            public bool OnGetPressed(Office.IRibbonControl control)

            {

                return Globals.ThisAddIn.ctp.Visible;

            }

     

    1. In your ctp_VisibleChanged, invalidate the ribbon or the button, so that the GetEnabled gets called, eg:

     

    ribbon.InvalidateControl(“toggleButton”)

     


    Subject: RE: Custom ribbon toggle button--how to set toggle state programatically...

     

    Thanks, Misha

    I made it that far:

    void ctp_VisibleChanged(object sender, EventArgs e)

            {

                //how do you toggle a ribbon button display programatically?

            }

     

    Here is my toggle button (excerpted from ribbon1.xml):

    <toggleButton id="toggleButton" label="Show/Hide Task Pane" screentip="Toggles the appearance of the PowerPoint Task Pane" onAction="OnToggleButton" />

     

    The question is: what now?

     

    Subject: RE: Custom ribbon toggle button--how to set toggle state programatically...

     

    CustomTaskPane has a VisibleChanged event. You can use this event to sync the state of the button.

     

    Subject: Custom ribbon toggle button--how to set toggle state programatically...

     

    I have a Word 2007 VSTO solution that implements a custom task pane and a ribbon customization that implements a toggle button to hide/show the custom task pane. So far so good.

     

    However if the user closes the custom task pane using the task pane’s close button, how can I toggle the state of the ribbon button to reflect the change?

     

    Thanks!

     

    Wednesday, August 9, 2006 7:02 PM
  • I will investigate the feasibility of getting an event when ActionsPane is being closed by the user.

    However, may I suggest you an alternative UI design. Instead of having a toggle button you can just have a button which will ensure the ActionsPane is visible. The user can still choose to close the ActionsPane by pressing the X.

    Thursday, August 10, 2006 5:01 AM
  • Below I did get a response from Savraj Dhanjal - the programm manager for Ribbon programmability.

    I would recommend creating a custom button with a custom image, and using our B2TR functions that we’ve exposed off of CommandBars to get the button to match the built-in one.  You would just write one-line callbacks that check the built-in control’s properties.

     

    In B2TR:

    Application.CommandBars.GetVisibleMso(“ViewDocumentActionsPane”) < returns true if the control is visible

    Application.CommandBars.GetEnabledMso(“ViewDocumentActionsPane”) < returns true if the control is enabled

    Application.CommandBars.ExecuteMso(“ViewDocumentActionsPane”) < executes the control (presses it)

    Application.CommandBars.GetPressedMso(“ViewDocumentActionsPane”) < returns whether the control should be down.

     

    If you invalidate the custom control on the Commandbars.OnUpdate event your custom control should almost always match the built-in one.

     

    Wednesday, September 6, 2006 11:58 PM

All replies

  • 1. Using CustomTaskPane from wokbook level customization will be possible, but not with the current VSTO v3 CTP. Your workbook customization will need to communicate with the add-in. It will need to get an access to addin's automation object using Application.COMAddin[<AddinName>].Object. The problem is that latest CTP can not initialize the COMAddin.Object property correctly, but this will be possible in the future. Also, I think you will run into problem when your workbook solution will affect global UI which will show in other workbooks as well. So, I think ActionsPane is the preferred solution for workbook level customization, but again I do not know your application requirement well.

    2. You can not change the title of the ActionsPane or disable the close button. The UI guidelines about TaskPanes in Office is that it should be an inobtrusive way of providing additional information to the user. Not something that will be stuch in your face all the time.

    3. I think the toggleButton question has also been answered on internal aliases. Here is the result:

    Subject: RE: Custom ribbon toggle button--how to set toggle state programatically...

     

    1. specify in your ribbon markup that the enabled state of the button is dynamic, eg:

     

    getPressed="OnGetPressed"

     

    1. Provide a matching callback, eg:

     

            public bool OnGetPressed(Office.IRibbonControl control)

            {

                return Globals.ThisAddIn.ctp.Visible;

            }

     

    1. In your ctp_VisibleChanged, invalidate the ribbon or the button, so that the GetEnabled gets called, eg:

     

    ribbon.InvalidateControl(“toggleButton”)

     


    Subject: RE: Custom ribbon toggle button--how to set toggle state programatically...

     

    Thanks, Misha

    I made it that far:

    void ctp_VisibleChanged(object sender, EventArgs e)

            {

                //how do you toggle a ribbon button display programatically?

            }

     

    Here is my toggle button (excerpted from ribbon1.xml):

    <toggleButton id="toggleButton" label="Show/Hide Task Pane" screentip="Toggles the appearance of the PowerPoint Task Pane" onAction="OnToggleButton" />

     

    The question is: what now?

     

    Subject: RE: Custom ribbon toggle button--how to set toggle state programatically...

     

    CustomTaskPane has a VisibleChanged event. You can use this event to sync the state of the button.

     

    Subject: Custom ribbon toggle button--how to set toggle state programatically...

     

    I have a Word 2007 VSTO solution that implements a custom task pane and a ribbon customization that implements a toggle button to hide/show the custom task pane. So far so good.

     

    However if the user closes the custom task pane using the task pane’s close button, how can I toggle the state of the ribbon button to reflect the change?

     

    Thanks!

     

    Wednesday, August 9, 2006 7:02 PM
  • Thanks Misha,

    Just a brief about the application:

    Need to setup an event.

    Record multiple actions under an event. (Use the document action task pane as an UI which contains buttons for specific actions)

    Display recorded actions on the worksheet.

    (Initially thought shall have the application as a excel template, so that users could choose the template while they open excel to perform their recording. However wasnt been able to succeed with this, hence using the workbook solution)

    Regarding my queries, when the user closes the Document Action task pane, the VisibleChanged event does not get triggered. Tried this option last evening, but didnt work. All I need to do now is control the visibility of the action pane with a toggle button on the ribbon. If the actionpane is on, the toggle button is pressed, otherwise pressed is off. I managed to control the action pane visible on/off with the toggle button, but need to control the toggle button when the action pane closes. Please suggest alternative to VisibleChanged using a takspane.

    Thanks

    Markand

    Thursday, August 10, 2006 4:42 AM
  • I will investigate the feasibility of getting an event when ActionsPane is being closed by the user.

    However, may I suggest you an alternative UI design. Instead of having a toggle button you can just have a button which will ensure the ActionsPane is visible. The user can still choose to close the ActionsPane by pressing the X.

    Thursday, August 10, 2006 5:01 AM
  • Thanks Misha,

    I would implement the button instead of the toggle button. However would like to know more about the action panes close event. Also would like to know more about the document level customizations available in the current release of vsto v3 and features that would be made available in the further releases (when would these release be made available)

    Just for information, would it be possible to add an add-in project into my existing workbook project, and make use of the add-in features only under this workbook. Also how do I get to disable the Recent Documents in my excel workbook, since I am changing the title name from Microsoft Excel to "My Workbook" (subsequent file opens from the recent documents also carry the title "My Workbook", instead of Microsoft Excel).

    Markand

    Thursday, August 10, 2006 5:13 AM
  • Not sure I can give you answers to all of your questions. I will try to answer some of those:

    See this post by Andrew Whitechapel on how to scope your add-in to a particular category of documents. He uses a custom property to hint the add-in that a particular workbook is of a "special" interest. There might be other approaches but this one seems very reasonable.

    To control the Recent Documents take a look at Application.RecentFiles collection.

    Unfortunately I can not speculate yet on the list of the features we are adding in v3. Since you are working with the CTP you might have a general idea.

    Thursday, August 10, 2006 6:52 AM
  • Will try Andrew's approach....

    Thanks a lot Misha & Cindy

    Markand

    Thursday, August 10, 2006 7:22 AM
  • Hi Misha,

    Regards to adding a toggleButton in a ribbon to Show/Hide a document action pane; I have managed to do it, by using the Excel command SmartDocPane toggleButton, which works perfectly showing and hiding my custom document action pane.

    <toggleButton idMso="SmartDocPane" size="large" label="Show Scoring Screen"/>

    However would like to change the image of this toggleButton. Tried using the getImage, but no luck.

    Please advice

    Regards
    Markand

     

     

    Monday, August 28, 2006 7:42 AM
  • Cool, I did not know about the SmartDocPane button.

    I believe you can not redefine the images used on built-in buttons.

    Tuesday, August 29, 2006 6:06 PM
  • Hi Misha,

    Thanks for the response. Well if we cannot redefine the images on built-in buttons, is there anyway I could create my own toggle Button (toggleButton id = "mytogglebutton") and define the functionalities / properties of the built-in button (SmartDocPane) button.

    Thanks

    Markand

    Friday, September 1, 2006 5:27 AM
  • Below I did get a response from Savraj Dhanjal - the programm manager for Ribbon programmability.

    I would recommend creating a custom button with a custom image, and using our B2TR functions that we’ve exposed off of CommandBars to get the button to match the built-in one.  You would just write one-line callbacks that check the built-in control’s properties.

     

    In B2TR:

    Application.CommandBars.GetVisibleMso(“ViewDocumentActionsPane”) < returns true if the control is visible

    Application.CommandBars.GetEnabledMso(“ViewDocumentActionsPane”) < returns true if the control is enabled

    Application.CommandBars.ExecuteMso(“ViewDocumentActionsPane”) < executes the control (presses it)

    Application.CommandBars.GetPressedMso(“ViewDocumentActionsPane”) < returns whether the control should be down.

     

    If you invalidate the custom control on the Commandbars.OnUpdate event your custom control should almost always match the built-in one.

     

    Wednesday, September 6, 2006 11:58 PM
  • Misha

    Are you aware of any changes in B2TR that would have removed InvalidateControl() and/or Invalidate() from the ribbon?

    I am working in Word (which I assume would be the same as Excel) but these functions do not semm to be available.

    Monday, October 16, 2006 2:14 PM