1

I'm trying to programmatically open "Queries & Connections" CommandBar. It's by default docked to the right (msoBarRight)

However, just setting .Visible = True opens it too narrow.
I tried to fix that by setting .Width but it just ignores it...
No problems if CommandBar is floating though.

I'm using Excel 365.
Example code below:

With Application.CommandBars("Queries and Connections")
    .Visible = True
    .Width = 350 'This part does nothing
End With
Ali
  • 45
  • 6

1 Answers1

2

Enforcing dock on the right made .Width work for me. Any other .Position works as well, but if you want pane to stay docked on the right, this works:

With Application.CommandBars("Queries and Connections")
    .Visible = True
    .Position = msoBarRight
    .Width = 400
End With
  • Thank you @Rafał . I had to add the snippet (see below) before your proposed solution. But thanks to your solution - it now works as expected. `If Not Application.CommandBars.GetPressedMso("ShowQueriesAndConnections") Then Application.CommandBars.ExecuteMso ("ShowQueriesAndConnections") End If` – Ali Jul 27 '22 at 15:26