Hi Jason,
Regarding your two questions, please see my answers below:
Q: how to set the sub menu bar by coding ?
A: Try the following code:
================================
Dim cb As CommandBar
Set cb = Application.CommandBars.Add("abc menu", msoBarTop, True, True)
Set cbSubMenu = cb.Controls.Add(Type:=10)
With cbSubMenu
.Caption = "Test"
.BeginGroup = True
End With
Set cbsubCtl = cbSubMenu.Controls.Add(Type:=msoControlButton)
With cbsubCtl
.Caption = "Hello World"
.FaceId = 1
End With
cb.Visible = True
================================
Q: I want to set the menu bar at the top of the screen by following
coding, but it doesn't work. set cb = commandbars("abc menu",
msoBarTop,,True)
A: Per my above test, the menu bar is at the top of tyhe main Access
window. Could you please let me know why you would like to move the menu
bar at the top of the screen? Per my knowledge, you need to call Windows
API to move your main Access window to the top of the screen so that the
title of your Access window can be hidden.
For example:
'First create a module to re-declare the related Win32 API
================================
Public Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As
Long) As Long
Private Declare Function apiFindWindow Lib "user32" Alias _
"FindWindowA" (ByVal strClass As String, _
ByVal lpWindow As String) As Long
Public Declare Function apiMoveWindow Lib "user32" Alias "MoveWindow"
(ByVal hWnd As Long, ByVal X As Long, ByVal Y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As
Long
================================
'Then move your window to hide the title
==================================
Dim nHeight, nSX, nSY As Long
Dim nRet As Long
Dim hWnd As Long
hWnd = Module4.apiFindWindow(vbNullString, "Microsoft Access")
nHeight = Module4.GetSystemMetrics(31)
nSX = Module4.GetSystemMetrics(0)
nSY = Module4.GetSystemMetrics(1)
nRet = Module4.apiMoveWindow(hWnd, 0, 0 - CInt(1.5 * nHeight), nSX, nSY +
nHeight, True)
===================================
You may also want the following reference:
http://www.mvps.org/access/api/api0007.htm
Hope this helps. If you have any other questions or concerns, please feel
free to let me know.
Best regards,
Charles Wang
Microsoft Online Community Support
===========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: (e-mail address removed).
===========================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for
non-urgent issues where an initial response from the community
or a Microsoft Support Engineer within 1 business day is acceptable.
Please note that each follow up response may take approximately
2 business days as the support professional working with you may
need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by
contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
============================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=========================================================