ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adjust position of a commandbar (https://www.excelbanter.com/excel-programming/325084-adjust-position-commandbar.html)

quartz[_2_]

Adjust position of a commandbar
 
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.

Greg Wilson

Adjust position of a commandbar
 
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


"quartz" wrote:

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.



All times are GMT +1. The time now is 05:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com