Reputation: 13
I have to write VBA script to select any item from Menu Bar from the code, but it did not work.
Please find below the code and suggest what should be the correct code.
Sub selectMenu()
Application.CommandBars("Worksheet Menu Bar").Controls("View").Controls("Arrange All").Execute
End Sub
Upvotes: 1
Views: 1754
Reputation: 33474
Windows.Arrange
The parameter could be either of xlArrangeStyleHorizontal
, xlArrangeStyleCascade
, xlArrangeStyleTiled
, xlArrangeStyleVertical
.
ref: (http://msdn.microsoft.com/en-us/library/office/aa221833(v=office.11).aspx)
Upvotes: 0
Reputation: 149325
If you are using >=xl2007
then you can use the ExecuteMso
to click on the Arrange All
Sub selectMenu()
Application.CommandBars.ExecuteMso ("WindowsArrangeAll")
End Sub
Upvotes: 2