Ali
Ali

Reputation: 45

Excel VBA - Unable to change width of docked "Queries & Connections"

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

Upvotes: 1

Views: 694

Answers (1)

Rafał Andrzejczak
Rafał Andrzejczak

Reputation: 36

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

Upvotes: 2

Related Questions