Do you know how to build standard "Window" menu on-the-fly to have not only standard menu entries but the dynamically changing list of open windows?
I cannot build by VBA code "Window" pulldown menu which will automatically watch and display the list of open windows. The problem is that I cannot add built-in CommandBarControl with Id = 830 to pulldown menu.
Run this code and try to recreate the "Window" pulldown menu structure using VBA:
Sub Test() Dim mbr As CommandBar Dim cbr As CommandBarControl Dim ctl As CommandBarControl Set mbr = CommandBars("Menu Bar") Set cbr = mbr.Controls("Window") For Each ctl In cbr.Controls Debug.Print Format(ctl.Index, "00"); ctl.Id; ctl.Caption Next End Sub
Probably I should use something like this example from MS Acess 97 online help (.Copy method) ?:
Function EnterNewName() CopyCommandBar "Menu Bar", "New Menu Bar" End Function Function CopyCommandBar(strOrigCBName As String, strNewCBName As String) As Boolean ' This procedure copies command bar named in strOrigCBName variable to new ' command bar named in strNewCBName variable. Dim cbrOriginal As CommandBar, intOrigCount As Integer Dim cbrCopy As CommandBar, cbrCtl As CommandBarControl On Error GoTo CBCopy_Err Set cbrOriginal = CommandBars(strOrigCBName) intOrigCount = cbrOriginal.Controls.Count Set cbrCopy = CommandBars.Add(strNewCBName) ' Make sure new command bar is visible. cbrCopy.Visible = True For Each cbrCtl In cbrOriginal.Controls cbrCtl.Copy cbrCopy Next cbrCtl Exit Function CBCopy_Err: MsgBox Err.Description Exit Function End Function
Any other ideas ?
Copyright © 1999-2008 by Shamil Salakhetdinov. All rights reserved.