1

I'm building a VSTO project with a simple action pane containing a treeview. Coming from VBA, things are similar, but not the same and I'm a bit confused.

What I want to do is load all sheets to the tree view, and give each node the color of the respective sheet. I'm getting an error at the commented line below, I believe the error is coming from the fact that the N.BackColor is in RGB and SH.Tab.Color is in colorcode.

The question is should I use a different property to get the same color type, or do I need to cast it. If I need to cast it please help me with this, as most of the documentation is in C#, and I'm not sure where to look for an answer

Private Sub ActionPane_SheetSearch_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim SH As Excel.Worksheet, N As TreeNode

        With Me
            .Width = 200
        End With

        With Me.TreeView1
            .ItemHeight = 20
            For Each SH In Globals.ThisWorkbook.Sheets
                N = .Nodes.Add(SH.Name)
                N.Tag = SH.CodeName
                'N.BackColor = SH.Tab.Color
            Next
        End With
End Sub

Also with .Width = 200 i'm trying to customize the with of the action pane, but it's ignoring the code or I'm not doing it correclty. I tried setting the starting width at the begining as well, it does not respond.

Please let me know how can I set the starting with, and also set the default position to left instead of right.

Private Sub ThisWorkbook_Startup() Handles Me.Startup

        Globals.ThisWorkbook.ActionsPane.Controls.Add(taskPane)
        Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = True
        taskPane.Width = 400
        taskPane.Show()

End Sub
Dumitru Daniel
  • 571
  • 4
  • 19
  • If there's no tab color set then `SH.Tab.Color` will return `False` (otherwise you will get a Long) – Tim Williams Dec 21 '21 at 00:46
  • `ActionsPane` has a `Width` property and see also https://learn.microsoft.com/en-us/visualstudio/vsto/actions-pane-overview?view=vs-2022#:~:text=Pane%22%5D.Width%20%3D%20200%3B-,Reposition%20the%20actions%20pane,-You%20cannot%20directly – Tim Williams Dec 21 '21 at 03:20

1 Answers1

0

Use the Custom task panes instead. The DockPosition property sets an enumerated value specifying the docked position of a CustomTaskPane object. The Width property sets the width of the task pane specified by the CustomTaskPane object.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45