Adjust position of a commandbar

G

Guest

I am using Excel 2003 with Windows XP.

I want to make the top left corner of a custom toolbar appear on the screen
in line with the top left corner of cell "A1".

I have tried using "Top = 0" and "Left = 0", which is where the top and left
of cell A1 is, but this doesn't work on the toolbar, which appears near
center of the screen. This toolbar is deleted and rebuilt on each execution
based on other data.

Can someone please clue me in on what I am doing wrong? All I need is for it
to appear in the correct position...thanks.

Thanks much in advance.
 
G

Guest

Try the following. Works for me. Do not execute from the VBE or the VBE Main
Window will serve as the ActiveWindow.

Sub PositionCB()
Dim x As Single, y As Single
With ActiveWindow
x = .PointsToScreenPixelsX(0)
y = .PointsToScreenPixelsY(0)
End With
With CommandBars("Custom 1")
.Left = x
.Top = y
End With
End Sub

Regards,
Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top