» Display a CommandBar centered on the screen using VBA in Microsoft Excel
VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
CATEGORY - Menus, Toolbars, Status bar in VBA
VERSION - All Microsoft Excel Versions
The macro also shows how you can get the screensize by using the function GetSystemMetrics32.
Declare Function GetSystemMetrics32 Lib "User32" _
Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
Sub CenterCommandBar()
Dim w As Long, h As Long
w = GetSystemMetrics32(0) ' screenwidth in points
h = GetSystemMetrics32(1) ' screenheight in points
With CommandBars("MyCommandBarName")
.Position = msoBarFloating
.Left = w / 2 - .Width / 2
.Top = h / 2 - .Height / 2
End With
End Sub
Book Store:
Recommended Books:
- Essentials of Accounting and Post Test Booklet 8, Eighth Edition
- Accounting Principles, with CD, 6th Edition
- Microsoft Excel 2002 Simply Visual
- The 11 Immutable Laws of Internet Branding
- Quantitative Methods in Derivatives Pricing: An Introduction to Computational Finance
- Millionaire Real Estate Mentor : The Secrets of Financial Freedom through Real Estate Investing
No comments have been submitted.

