ActionsPane Interface
Represents a custom user interface for the Document Actions task pane in a document-level customization for Word or Excel.
Namespace: Microsoft.Office.Tools
Assembly: Microsoft.Office.Tools.Common (in Microsoft.Office.Tools.Common.dll)
Syntax
'Declaration
<GuidAttribute("b835a67a-c3c0-45ba-9a3f-c878bf531dd5")> _
Public Interface ActionsPane _
Inherits IDisposable
[GuidAttribute("b835a67a-c3c0-45ba-9a3f-c878bf531dd5")]
public interface ActionsPane : IDisposable
The ActionsPane type exposes the following members.
Properties
Name | Description | |
---|---|---|
AccessibilityObject | Gets the AccessibleObject that is assigned to the actions pane. | |
AccessibleDefaultActionDescription | Gets or sets the default action description of the actions pane. This description is used by accessibility client applications. | |
AccessibleDescription | Gets or sets the accessible description of the actions pane. This description is used by accessibility client applications. | |
AccessibleName | Gets or sets the accessible name of the actions pane. This name is used by accessibility client applications. | |
AccessibleRole | Gets or sets the accessible role of the actions pane. | |
ActiveControl | Gets or sets the active control on the actions pane. | |
AllowDrop | Gets or sets a value that indicates whether the actions pane can accept data that the user drags onto it. | |
Anchor | Gets or sets the edges of the container to which the actions pane is bound and determines how the user control is resized with its parent. | |
AutoRecover | Gets or sets a value that indicates whether the actions pane solution automatically re-attaches to the document when it is detached. | |
AutoScaleDimensions | Gets or sets the dimensions that the actions pane was designed to. | |
AutoScaleMode | Gets or sets the automatic scaling mode of the actions pane. | |
AutoScroll | Gets or sets a value indicating whether the actions pane enables the user to scroll to any controls placed outside of its visible boundaries. | |
AutoScrollMargin | Gets or sets the size of the auto-scroll margin for the actions pane. | |
AutoScrollMinSize | Gets or sets the minimum size of the auto-scroll for the actions pane. | |
AutoScrollOffset | Gets or sets where the actions pane is scrolled to when the ScrollControlIntoView method is called. | |
AutoScrollPosition | Gets or sets the location of the auto-scroll position for the actions pane. | |
AutoSize | Infrastructure. This property is not supported by the actions pane. | |
AutoSizeMode | Gets or sets the mode by which the actions pane control automatically resizes itself. | |
AutoValidate | Gets or sets a value that indicates whether controls in the actions pane will be automatically validated when the focus changes. | |
BackColor | Gets or sets the background color for the actions pane. | |
BackgroundImage | Gets or sets the background image displayed in the actions pane. | |
BackgroundImageLayout | Gets or sets the position and behavior of a background image in the actions pane. | |
BindingContext | Gets or sets an object that is used to keep all controls on the actions pane that are bound to the same data source synchronized. | |
BorderStyle | Gets or sets the border style of the actions pane. | |
Bottom | Gets the distance, in pixels, between the bottom edge of the actions pane and the top edge of its container's client area. | |
Bounds | Gets or sets the size and location of the actions pane control including its nonclient elements, in pixels, relative to its parent. | |
CanFocus | Gets a value indicating whether the actions pane can receive focus. | |
CanSelect | Gets a value indicating whether the actions pane can be selected. | |
Capture | Gets or sets a value indicating whether the actions pane has captured the mouse. | |
CausesValidation | Gets or sets a value indicating whether the actions pane causes validation to be performed on any controls that require validation when it receives focus. | |
ClientRectangle | Gets the rectangle that represents the client area of the actions pane. | |
ClientSize | Gets or sets the height and width of the client area of the actions pane. | |
CompanyName | Gets the name of the company or creator of the application containing the actions pane. | |
Container | Infrastructure. This property is not supported by the actions pane. | |
ContainsFocus | Gets a value indicating whether the actions pane, or one of its child controls, currently has the input focus. | |
ContextMenu | Gets or sets the shortcut menu associated with the actions pane. | |
ContextMenuStrip | Gets or sets the ContextMenuStrip associated with the actions pane. | |
Controls | Gets the collection of controls contained within the actions pane. | |
Created | Gets a value indicating whether the actions pane has been created. | |
CurrentAutoScaleDimensions | Gets the current run-time dimensions of the screen. | |
Cursor | Gets or sets the cursor that is displayed when the mouse pointer is over the actions pane. | |
DataBindings | Gets the data bindings for the actions pane. | |
DisplayRectangle | Gets the rectangle that represents the display area of the actions pane. | |
Disposing | Gets a value indicating whether the actions pane is in the process of disposing. | |
Dock | Gets or sets which actions pane control borders are docked to its parent and determines how the actions pane control is resized with its parent. | |
DockPadding | Infrastructure. This property is not supported by the actions pane. | |
Enabled | Gets or sets a value indicating whether the actions pane can respond to user interaction. | |
Focused | Gets a value indicating whether the actions pane has input focus. | |
Font | Gets or sets the font of the text displayed by the actions pane. | |
ForeColor | Gets or sets the foreground color of the actions pane. | |
Handle | Gets the window handle that the actions pane control is bound to. | |
HasChildren | Gets a value that indicates whether the control contains one or more child controls. | |
Height | Gets or sets the height of the actions pane control. | |
HorizontalScroll | Gets the characteristics associated with the horizontal scroll bar. | |
ImeMode | Gets or sets the Input Method Editor (IME) mode of the actions pane. | |
InvokeRequired | Gets a value indicating whether the caller must call an invoke method when making method calls to the actions pane control because the caller is on a different thread than the one the actions pane control was created on. | |
IsAccessible | Gets or sets a value that indicates whether the actions pane is visible to accessibility applications. | |
IsDisposed | Gets a value that indicates whether the actions pane control has been disposed of. | |
IsHandleCreated | Gets a value that indicates whether the actions pane control has a handle associated with it. | |
IsMirrored | Gets a value that indicates whether the actions pane is mirrored. | |
LayoutEngine | Gets a cached instance of the actions pane control's layout engine. | |
Left | Gets or sets the distance, in pixels, between the left edge of the actions pane control and the left edge of its container's client area. | |
Location | Gets or sets the coordinates of the upper-left corner of the actions pane relative to the upper-left corner of its container. | |
Margin | Gets or sets the space between controls. | |
MaximumSize | Gets or sets the size that is the upper limit that GetPreferredSize can specify. | |
MinimumSize | Gets or sets the size that is the lower limit that GetPreferredSize can specify. | |
Name | Gets or sets the name of the actions pane control. | |
Orientation | Gets a value that indicates whether the placement of the actions pane is vertical or horizontal. | |
Padding | Gets or sets padding within the actions pane. | |
Parent | Gets or sets the parent container of the actions pane. | |
ParentForm | Infrastructure. This property is not supported by the actions pane. | |
PreferredSize | Gets the size of the rectangular area into which the actions pane can fit. | |
ProductName | Gets the product name of the assembly that contains the actions pane. | |
ProductVersion | Gets the version of the assembly that contains the actions pane. | |
RecreatingHandle | Gets a value that indicates whether the actions pane control is currently re-creating its handle. | |
Region | Gets or sets the window region associated with the actions pane. | |
Right | Gets the distance, in pixels, between the right edge of the actions pane and the left edge of its container's client area. | |
RightToLeft | Gets or sets a value indicating whether the actions pane's elements are aligned to support locales using right-to-left fonts. | |
Site | Gets or sets the site of the actions pane. | |
Size | Gets or sets the height and width of the actions pane control. | |
StackOrder | Gets or sets a value that indicates the direction that the controls are stacked on the actions pane. | |
TabIndex | Gets or sets the tab order of the actions pane within its container. | |
TabStop | Gets or sets a value indicating whether the user can give the focus to the actions pane by using the TAB key. | |
Tag | Gets or sets the object that contains data about the actions pane. | |
Text | Infrastructure. This property is not supported by the actions pane. | |
Top | Gets or sets the distance, in pixels, between the top edge of the actions pane control and the top edge of its container's client area. | |
TopLevelControl | Infrastructure. This property is not supported by the actions pane. | |
UseWaitCursor | Gets or sets a value indicating whether to use the wait cursor for the actions pane and all child controls. | |
VerticalScroll | Gets the characteristics associated with the vertical scroll bar. | |
Visible | Gets or sets a value that indicates whether the ActionsPane is visible. | |
Width | Gets or sets the width of the actions pane control. | |
WindowTarget | Infrastructure. This property is not supported by the actions pane. |
Top
Methods
Name | Description | |
---|---|---|
BeginInit | Infrastructure. | |
BeginInvoke(Delegate) | Executes the specified delegate asynchronously on the thread that the actions pane control's underlying handle was created on. | |
BeginInvoke(Delegate, array<Object[]) | Executes the specified delegate asynchronously with the specified arguments, on the thread that the actions pane control's underlying handle was created on. | |
BringToFront | Brings the actions pane control to the front of the z-order. | |
Clear | Detaches the actions pane solution from the document. | |
Contains | Returns a value that indicates whether the specified control is a child of the actions pane. | |
CreateControl | Forces the creation of the visible actions pane control, including the creation of the handle and any visible child controls. | |
CreateGraphics | Creates the Graphics for the actions pane control. | |
Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from IDisposable.) | |
DoDragDrop | Begins a drag-and-drop operation. | |
DrawToBitmap | Supports rendering to the specified bitmap. | |
EndInit | Infrastructure. | |
EndInvoke | Retrieves the return value of the specified asynchronous operation. | |
FindForm | Retrieves the form that the actions pane control is on. | |
Focus | Sets input focus to the actions pane. | |
GetChildAtPoint(Point) | Retrieves the child control that is located at the specified coordinates. | |
GetChildAtPoint(Point, GetChildAtPointSkip) | Retrieves the child control that is located at the specified coordinates, specifying whether to ignore child controls of a certain type. | |
GetContainerControl | Returns the next ContainerControl up the control's chain of parent controls. | |
GetNextControl | Retrieves the next control forward or back in the tab order of child controls. | |
GetPreferredSize | Retrieves the size of a rectangular area into which the actions pane can be fitted. | |
Hide | Removes the ActionsPane and the controls from the task pane user interface, but leaves the task pane visible. | |
Invalidate() | Invalidates the entire surface of the actions pane and causes the actions pane to be redrawn. | |
Invalidate(Boolean) | Invalidates the entire surface of the actions pane and causes a paint message to be sent to the actions pane. Optionally, invalidates the child controls assigned to the actions pane. | |
Invalidate(Rectangle) | Invalidates the specified region of the actions pane (adds it to the actions pane's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the actions pane. | |
Invalidate(Region) | Invalidates the specified region of the actions pane (adds it to the actions pane's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the actions pane. | |
Invalidate(Rectangle, Boolean) | Invalidates the specified region of the actions pane (adds it to the actions pane's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the actions pane. Optionally, invalidates the child controls assigned to the actions pane. | |
Invalidate(Region, Boolean) | Invalidates the specified region of the actions pane (adds it to the actions pane's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the actions pane. Optionally, invalidates the child controls assigned to the actions pane. | |
Invoke(Delegate) | Executes the specified delegate on the thread that owns the actions pane's underlying window handle. | |
Invoke(Delegate, array<Object[]) | Executes the specified delegate, on the thread that owns the actions pane's underlying window handle, with the specified list of arguments. | |
PerformAutoScale | Performs scaling of the actions pane and its children. | |
PerformLayout() | Forces the actions pane to apply layout logic to all its child controls. | |
PerformLayout(Control, String) | Forces the actions pane to apply layout logic to all its child controls. | |
PointToClient | Computes the location of the specified screen point into client coordinates. | |
PointToScreen | Computes the location of the specified client point into screen coordinates. | |
PreProcessControlMessage | Preprocesses keyboard or input messages within the message loop before they are dispatched. | |
PreProcessMessage | Preprocesses keyboard or input messages within the message loop before they are dispatched. | |
RectangleToClient | Computes the size and location of the specified screen rectangle in client coordinates. | |
RectangleToScreen | Computes the size and location of the specified client rectangle in screen coordinates. | |
Refresh | Forces the actions pane to invalidate its client area and immediately redraw itself and any child controls. | |
ResetBackColor | Infrastructure. This method is not supported by the actions pane. | |
ResetBindings | Infrastructure. This method is not supported by the actions pane. | |
ResetCursor | Infrastructure. This method is not supported by the actions pane. | |
ResetFont | Infrastructure. This method is not supported by the actions pane. | |
ResetForeColor | Infrastructure. This method is not supported by the actions pane. | |
ResetImeMode | Infrastructure. This method is not supported by the actions pane. | |
ResetRightToLeft | Infrastructure. This method is not supported by the actions pane. | |
ResetText | Infrastructure. This method is not supported by the actions pane. | |
ResumeLayout() | Resumes usual layout logic. | |
ResumeLayout(Boolean) | Resumes usual layout logic, optionally forcing an immediate layout of pending layout requests. | |
Scale | Scales the actions pane and all child controls by the specified scaling factor. | |
ScrollControlIntoView | Scrolls the specified child control into view. | |
Select | Activates the actions pane. | |
SelectNextControl | Activates the next control. | |
SendToBack | Sends the actions pane control to the back of the z-order. | |
SetAutoScrollMargin | Sets the size of the auto-scroll margins. | |
SetBounds(Int32, Int32, Int32, Int32) | Sets the bounds of the actions pane to the specified location and size. | |
SetBounds(Int32, Int32, Int32, Int32, BoundsSpecified) | Sets the specified bounds of the actions pane to the specified location and size. | |
Show | Displays the ActionsPane on the task pane, including all controls that have been added to the ActionsPane, but does not display the task pane if the task pane is not visible. | |
SuspendLayout | Temporarily suspends the layout logic for the actions pane. | |
Update | Causes the actions pane to redraw the invalidated regions within its client area. | |
Validate() | Verifies the contents of the actions pane by causing the Validating and Validated events to occur, in that order. | |
Validate(Boolean) | Verifies the contents of the actions pane; conditionally dependent on whether automatic validation is turned on. | |
ValidateChildren() | Causes all of the child controls that support validation to validate their data. | |
ValidateChildren(ValidationConstraints) | Causes all of the child controls that support validation to validate their data. |
Top
Events
Name | Description | |
---|---|---|
AutoSizeChanged | Infrastructure. This event is not supported by the actions pane. | |
AutoValidateChanged | Occurs when the AutoValidate property changes. | |
BackColorChanged | Occurs when the value of the BackColor property changes. | |
BackgroundImageChanged | Occurs when the value of the BackgroundImage property changes. | |
BackgroundImageLayoutChanged | Occurs when the BackgroundImageLayout property changes. | |
BindingContextChanged | Occurs when the value of the BindingContext property changes. | |
CausesValidationChanged | Occurs when the value of the CausesValidation property changes. | |
ChangeUICues | Occurs when the focus or keyboard user interface (UI) cues change. | |
Click | Occurs when the actions pane is clicked. | |
ClientSizeChanged | Occurs when the value of the ClientSize property changes. | |
ContextMenuChanged | Occurs when the value of the ContextMenu property changes. | |
ContextMenuStripChanged | Occurs when the value of the ContextMenuStrip property changes. | |
ControlAdded | Occurs when a new control is added to the Controls collection. | |
ControlRemoved | Occurs when a control is removed from the Controls collection. | |
CursorChanged | Occurs when the value of the Cursor property changes. | |
Disposed | Occurs when the actions pane is disposed. | |
DockChanged | Occurs when the value of the Dock property changes. | |
DoubleClick | Occurs when the actions pane is double-clicked. | |
DragDrop | Occurs when a drag-and-drop operation is completed. | |
DragEnter | Occurs when an object is dragged into the actions pane's bounds. | |
DragLeave | Occurs when an object is dragged out of the actions pane's bounds. | |
DragOver | Occurs when an object is dragged over the actions pane's bounds. | |
EnabledChanged | Occurs when the Enabled property value has changed. | |
Enter | Occurs when the actions pane is entered. | |
FontChanged | Occurs when the Font property value changes. | |
ForeColorChanged | Occurs when the ForeColor property value changes. | |
GiveFeedback | Occurs during a drag operation. | |
GotFocus | Occurs when the actions pane receives focus. | |
HandleCreated | Occurs when a handle is created for the actions pane. | |
HandleDestroyed | Occurs when the actions pane's handle is in the process of being destroyed. | |
HelpRequested | Occurs when the user requests help for the actions pane. | |
ImeModeChanged | Occurs when the ImeMode property changes. | |
Invalidated | Occurs when the actions pane's display requires redrawing. | |
KeyDown | Occurs when a key is pressed while the actions pane has focus. | |
KeyPress | Occurs when a key is pressed while the actions pane has focus. | |
KeyUp | Occurs when a key is released while the actions pane has focus. | |
Layout | Occurs when the actions pane should reposition its child controls. | |
Leave | Occurs when the input focus leaves the actions pane. | |
Load | Occurs before the actions pane becomes visible for the first time. | |
LocationChanged | Occurs when the Location property value has changed. | |
LostFocus | Occurs when the actions pane loses focus. | |
MarginChanged | Occurs when the actions pane's margin changes. | |
MouseCaptureChanged | Occurs when the actions pane loses or gains mouse capture. | |
MouseClick | Occurs when the actions pane is clicked by the mouse. | |
MouseDoubleClick | Occurs when the actions pane is double clicked by the mouse. | |
MouseDown | Occurs when the mouse pointer is over the actions pane and a mouse button is pressed. | |
MouseEnter | Occurs when the mouse pointer enters the actions pane. | |
MouseHover | Occurs when the mouse pointer rests on the actions pane. | |
MouseLeave | Occurs when the mouse pointer leaves the actions pane. | |
MouseMove | Occurs when the mouse pointer is moved over the actions pane. | |
MouseUp | Occurs when the mouse pointer is over the actions pane and a mouse button is released. | |
MouseWheel | Occurs when the mouse wheel moves while the actions pane has focus. | |
Move | Occurs when the actions pane is moved. | |
OrientationChanged | Occurs when the Orientation of the actions pane changes. | |
PaddingChanged | Occurs when the actions pane's padding changes. | |
Paint | Occurs when the actions pane is redrawn. | |
ParentChanged | Occurs when the Parent property value changes. | |
PreviewKeyDown | Occurs before the KeyDown event when a key is pressed while focus is on this control. | |
QueryAccessibilityHelp | Occurs when an AccessibleObject is providing help to accessibility applications. | |
QueryContinueDrag | Occurs during a drag-and-drop operation and enables the drag source to determine whether the drag-and-drop operation should be canceled. | |
RegionChanged | Occurs when the value of the Region property changes. | |
Resize | Occurs when the actions pane is resized. | |
RightToLeftChanged | Occurs when the RightToLeft property value changes. | |
Scroll | Occurs when the user or code scrolls through the client area. | |
SizeChanged | Occurs when the Size property value changes. | |
StyleChanged | Occurs when the actions pane style changes. | |
SystemColorsChanged | Occurs when the system colors change. | |
TabIndexChanged | Occurs when the TabIndex property value changes. | |
TabStopChanged | Occurs when the TabStop property value changes. | |
TextChanged | Infrastructure. This event is not supported by the actions pane. | |
Validated | Occurs when the actions pane is finished validating. | |
Validating | Occurs when the actions pane is validating. | |
VisibleChanged | Occurs when the Visible property value changes. |
Top
Remarks
Every document-level customization for Excel or Word exposes an ActionsPane object. You can use this object to customize the user interface of the Document Actions task pane in a document-level project. To get the ActionsPane object, use the ActionsPane field of the ThisDocument class (for Word) or the ThisWorkbook class (for Excel) in your project. For more information, see Actions Pane Overview.
Each ActionsPane object extends an underlying Windows Forms UserControl that provides a user interface that you can customize. Most of the ActionsPane members correspond to members of the underlying UserControl. Use the following ActionsPane members to access actions pane-specific functionality:
Clear method. Use this method to detach the actions pane from the document or workbook.
AutoRecover property. Use this property to prevent or allow end users to detach the actions pane from the document or workbook.
Orientation property. Use this property to determine whether the actions pane is docked to the top or bottom of the document or workbook, or to the left or right of the document or workbook.
StackOrder property. Use this property to specify the direction that controls are stacked on the actions pane.
OrientationChanged event. Use this property to determine when the actions pane is docked to a different location.
Note
This interface is implemented by the Visual Studio Tools for Office runtime. It is not intended to be implemented in your code. For more information, see Visual Studio Tools for Office Runtime Overview.
Usage
This documentation describes the version of this type that is used in Office projects that target the .NET Framework 4 and the .NET Framework 4.5. In projects that target the .NET Framework 3.5, this type might have different members and the code examples provided for this type might not work. For documentation about this type in projects that target the .NET Framework 3.5, see the following reference section in the Visual Studio 2008 documentation: https://go.microsoft.com/fwlink/?LinkId=160658.
Examples
The following code example demonstrates how to create a simple actions pane that automatically adjusts the alignment of its contents. When the user changes the orientation of the actions pane by moving the actions pane to a different part of the application window, or the user clicks on a Button control in the actions pane, the Orientation property is used to determine the new value of the StackOrder property. To run this code, call the InitActionsPane method from the ThisWorkbook_Startup event handler of a document-level project for Excel.
Private Sub InitActionsPane()
With Globals.ThisWorkbook.ActionsPane
.Clear()
.Visible = True
.AutoRecover = True
End With
AddHandler Globals.ThisWorkbook.ActionsPane.OrientationChanged, _
AddressOf ActionsPane_OrientationChanged
ResetStackOrder()
' Create the button that will update the stack order.
Dim button1 As New Button()
button1.Text = "Change stack order"
AddHandler button1.Click, AddressOf button1_Click
' Create two more buttons that do nothing.
Dim button2 As New Button()
button2.Text = "Button 2"
Dim button3 As New Button()
button3.Text = "Button 3"
Globals.ThisWorkbook.ActionsPane.Controls.AddRange(New Control() _
{button1, button2, button3})
End Sub
' Switch the stack order according to the current orientation.
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
If Globals.ThisWorkbook.ActionsPane.Orientation = _
Orientation.Horizontal Then
If Globals.ThisWorkbook.ActionsPane.StackOrder = _
Microsoft.Office.Tools.StackStyle.FromLeft Then
Globals.ThisWorkbook.ActionsPane.StackOrder = _
Microsoft.Office.Tools.StackStyle.FromRight
Else
Globals.ThisWorkbook.ActionsPane.StackOrder = _
Microsoft.Office.Tools.StackStyle.FromLeft
End If
Else
If Globals.ThisWorkbook.ActionsPane.StackOrder = _
Microsoft.Office.Tools.StackStyle.FromTop Then
Globals.ThisWorkbook.ActionsPane.StackOrder = _
Microsoft.Office.Tools.StackStyle.FromBottom
Else
Globals.ThisWorkbook.ActionsPane.StackOrder = _
Microsoft.Office.Tools.StackStyle.FromTop
End If
End If
End Sub
Private Sub ActionsPane_OrientationChanged(ByVal sender As Object, _
ByVal e As EventArgs)
ResetStackOrder()
End Sub
' Readjust the stack order so that it matches the current orientation.
Sub ResetStackOrder()
If Globals.ThisWorkbook.ActionsPane.Orientation = _
Orientation.Horizontal Then
If (Globals.ThisWorkbook.ActionsPane.StackOrder = _
Microsoft.Office.Tools.StackStyle.FromTop Or _
Globals.ThisWorkbook.ActionsPane.StackOrder = _
Microsoft.Office.Tools.StackStyle.FromBottom) Then
Globals.ThisWorkbook.ActionsPane.StackOrder = _
Microsoft.Office.Tools.StackStyle.FromLeft
End If
End If
If Globals.ThisWorkbook.ActionsPane.Orientation = _
Orientation.Vertical Then
If (Globals.ThisWorkbook.ActionsPane.StackOrder = _
Microsoft.Office.Tools.StackStyle.FromLeft Or _
Globals.ThisWorkbook.ActionsPane.StackOrder = _
Microsoft.Office.Tools.StackStyle.FromRight) Then
Globals.ThisWorkbook.ActionsPane.StackOrder = _
Microsoft.Office.Tools.StackStyle.FromTop
End If
End If
End Sub
private void InitActionsPane()
{
Globals.ThisWorkbook.ActionsPane.Clear();
Globals.ThisWorkbook.ActionsPane.Visible = true;
Globals.ThisWorkbook.ActionsPane.AutoRecover = true;
Globals.ThisWorkbook.ActionsPane.OrientationChanged +=
new EventHandler(ActionsPane_OrientationChanged);
ResetStackOrder();
// Create the button that will update the stack order.
Button button1 = new Button();
button1.Text = "Change stack order";
button1.Click += new EventHandler(button1_Click);
// Create two more buttons that do nothing.
Button button2 = new Button();
button2.Text = "Button 2";
Button button3 = new Button();
button3.Text = "Button 3";
Globals.ThisWorkbook.ActionsPane.Controls.AddRange(
new Control[] { button1, button2, button3 });
}
// Switch the stack order according to the current orientation.
void button1_Click(object sender, EventArgs e)
{
if (Globals.ThisWorkbook.ActionsPane.Orientation ==
Orientation.Horizontal)
{
if (Globals.ThisWorkbook.ActionsPane.StackOrder ==
Microsoft.Office.Tools.StackStyle.FromLeft)
{
Globals.ThisWorkbook.ActionsPane.StackOrder =
Microsoft.Office.Tools.StackStyle.FromRight;
}
else
{
Globals.ThisWorkbook.ActionsPane.StackOrder =
Microsoft.Office.Tools.StackStyle.FromLeft;
}
}
else
{
if (Globals.ThisWorkbook.ActionsPane.StackOrder ==
Microsoft.Office.Tools.StackStyle.FromTop)
{
Globals.ThisWorkbook.ActionsPane.StackOrder =
Microsoft.Office.Tools.StackStyle.FromBottom;
}
else
{
Globals.ThisWorkbook.ActionsPane.StackOrder =
Microsoft.Office.Tools.StackStyle.FromTop;
}
}
}
void ActionsPane_OrientationChanged(object sender, EventArgs e)
{
ResetStackOrder();
}
// Readjust the stack order so that it matches the current orientation.
void ResetStackOrder()
{
if (Globals.ThisWorkbook.ActionsPane.Orientation ==
Orientation.Horizontal &&
(Globals.ThisWorkbook.ActionsPane.StackOrder ==
Microsoft.Office.Tools.StackStyle.FromTop ||
Globals.ThisWorkbook.ActionsPane.StackOrder ==
Microsoft.Office.Tools.StackStyle.FromBottom))
{
Globals.ThisWorkbook.ActionsPane.StackOrder =
Microsoft.Office.Tools.StackStyle.FromLeft;
}
if (Globals.ThisWorkbook.ActionsPane.Orientation ==
Orientation.Vertical &&
(Globals.ThisWorkbook.ActionsPane.StackOrder ==
Microsoft.Office.Tools.StackStyle.FromLeft ||
Globals.ThisWorkbook.ActionsPane.StackOrder ==
Microsoft.Office.Tools.StackStyle.FromRight))
{
Globals.ThisWorkbook.ActionsPane.StackOrder =
Microsoft.Office.Tools.StackStyle.FromTop;
}
}
See Also
Reference
Microsoft.Office.Tools Namespace