473,595 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Programmaticall y copy custom shortcut menu bars (command bars)?

Hi all,

I've read through the archives on this, and scoured the web, to little
avail.

There has to be a way to move custom menu bars (or menubars, or command
bars, or popup command bars, or whatever) from one database to another,
because it's an interface import option. I'm happy to slog through
coding it myself, but I need a few pointers. Anyone out there done
this, or found code templates for it? Seems like the CommandBar object
belongs to the Office library--how do you attach that to a database
then, using code only?

Just in case: yes, I know about File > Get external data > Import as a
copying method. I wish to do this purely through automation and DAO,
so that's not an option.

Any help would be greatly appreciated.

Jan 19 '06 #1
12 6755
downwitch wrote:
Hi all,

I've read through the archives on this, and scoured the web, to little
avail.

There has to be a way to move custom menu bars (or menubars, or command
bars, or popup command bars, or whatever) from one database to another,
because it's an interface import option. I'm happy to slog through
coding it myself, but I need a few pointers. Anyone out there done
this, or found code templates for it? Seems like the CommandBar object
belongs to the Office library--how do you attach that to a database
then, using code only?

Just in case: yes, I know about File > Get external data > Import as a
copying method. I wish to do this purely through automation and DAO,
so that's not an option.

Any help would be greatly appreciated.

I did this a long time ago by importing the table MSysCmdbars. Of
course the mdb with the code is on my old computer which has been
disassemble so I don't have it. I can't remember what I did because
usually the system tables are hidden and I was able to unhide the table
then import or I was able to connect/link to the table and append to the
new database table or else delete the new database table and append in.
Whatever...it worked. I hope this gives you a starting point.
Jan 20 '06 #2
Thanks, but I think MSysCmdbars disappeared after 97. In any case,
it's no longer visible, even with system tables visible.

Jan 20 '06 #3
The top couple are très ancient but might work in 97; the bottom
couple are not so très ancient and might work in later versions:
Sub test()
GetMenus "C:\Documen ts and Settings\Lyle Fairfield\My
Documents\Acces s\northwind.mdb ", _
"NorthwindCusto mMenuBar"
End Sub

Sub GetMenus(ByVal dbsName As String, ParamArray MenuNames())
Dim bConfirmActionQ ueries As Boolean
Dim vMenuName As Variant
Dim rst As Recordset

On Error Resume Next

bConfirmActionQ ueries = GetOption("Conf irm Action Queries")
If bConfirmActionQ ueries Then SetOption "Confirm Action Queries",
False

With DBEngine(0)(0)

Err = 0
.TableDefs("MSy sCmdBars").Name = .TableDefs("MSy sCmdBars").Name
If Err = 3265 Then 'table doesn't exist
.Execute "SELECT * INTO MSysCmdBars " _
& "FROM MSysCmdBars IN '" & dbsName & "' WHERE NO;"
.Execute "CREATE INDEX TbIndex ON MSysCmdBars (TbName) WITH
PRIMARY;"
End If
On Error GoTo 0
If UBound(MenuName s) = -1 Then 'no elements
.Execute "INSERT INTO MSysCmdBars " _
& "SELECT * FROM MSysCmdBars IN '" & dbsName & "';"
Else
For Each vMenuName In MenuNames
.Execute "INSERT INTO MSysCmdBars " _
& "SELECT * FROM MSysCmdBars IN '" & dbsName & "' " _
& "WHERE TBName = '" & vMenuName & "';"
Next vMenuName
End If

.TableDefs.Refr esh
Set rst = .TableDefs("MSy sCmdBars").Open Recordset
With rst
If Not (.BOF = True And .EOF = True) Then
.MoveFirst
On Error Resume Next
Do
CommandBars.Add (!TBName)
.MoveNext
Loop Until .EOF
On Error GoTo 0
End If
End With
Set rst = Nothing
End With

If bConfirmActionQ ueries Then SetOption "Confirm Action Queries",
True

End Sub

Sub g()
With WizHook
.Key = 51488399
.WizCopyCmdbars "C:\Documen ts and Settings\Lyle Fairfield\My
Documents\Acces s\ESO\EsoAdmin. adp"
End With
End Sub

Sub g1()
With WizHook
.Key = 51488399
.WizCopyCmdbars "C:\Documen ts and Settings\Lyle Fairfield\My
Documents\Acces s\northwind.mdb "
End With
End Sub

Jan 20 '06 #4
Well... That felt very exciting for a moment. I'd never heard of the
fancy WizHook, the undocumented tool! The gold mine, the magic key!

But no. The first bit of code founders because there's no MSysCmdBars
past 97. And according to the little bit of doc I found on the web,
2002 is the first version that supported the WizHook method.

I, naturally, am using 2000. So I get the dreaded Error 438 Object
doesn't support this property or method. So thanks Lyle, but no dice.

Did make me wonder, however, whether there might not be some shadow
documentation out there of the wizard mdes-- acwztool.mde,
acwzmain.mde, and acwzlib.mde--and whether command-bar stuff might live
in there.

Any other ideas?

Jan 20 '06 #5
Wizhook was definitely in AC2K. Peter Walker was the first to post
about it shortly after AC2K was shipped. I can verify that
(.WizCopyCmdBar s) exists and works in Ac2002 and Ac2003. It seems then
that it's missing from AC2K; arrrrrrrggggggg ghhhhhh.
****
If we are in hack land this is quite clumsy but TTBOMK one can create
CmdBars in AC97 then copy MSysCmdBars from the AC97 db to an AC>97 db.
Limited testing shows that the toolbars now work and can be transferred
to and from AC>97 dbs
(and updated) using the MSysCmdBars table. My guess is that MS removed
the table without removing the default use of the table. But this is on
the cusp of being ridiculous.
****
Life is grand.

Jan 20 '06 #6
Sky

"downwitch" <do*******@gmai l.com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .

Any other ideas?


You could start with something like below.
- Steve

' Copy a command bar or toolbar to a new one
' Example: CommandBarCopy "Form View", "tbrFormViewNew "

Public Function CommandBarCopy( strCbrOrigName As String, strCbrNewName As
String) As Boolean
Dim cbrNew As CommandBar, ctl As CommandBarContr ol
On Error GoTo Problem
Set cbrNew = CommandBars.Add (strCbrNewName)
cbrNew.Visible = True
For Each ctl In CommandBars(str CbrOrigName).Co ntrols
ctl.Copy cbrNew
Next ctl
Set ctl = Nothing
Set cbrNew = Nothing
Exit Function
Problem:
MsgBox Err.Description , vbCritical, "CommandBar Copy Error"
End Function


Jan 20 '06 #7
Wow, a 97 pass-through. I never would have thought of that! Nor, I
think, have I the patience.

But I agree, life *is* grand.

Lyle Fairfield wrote:
Wizhook was definitely in AC2K. Peter Walker was the first to post
about it shortly after AC2K was shipped. I can verify that
(.WizCopyCmdBar s) exists and works in Ac2002 and Ac2003. It seems then
that it's missing from AC2K; arrrrrrrggggggg ghhhhhh.
****
If we are in hack land this is quite clumsy but TTBOMK one can create
CmdBars in AC97 then copy MSysCmdBars from the AC97 db to an AC>97 db.
Limited testing shows that the toolbars now work and can be transferred
to and from AC>97 dbs
(and updated) using the MSysCmdBars table. My guess is that MS removed
the table without removing the default use of the table. But this is on
the cusp of being ridiculous.
****
Life is grand.


Jan 21 '06 #8
Thanks Steve, but that actually only copies a command bar within the
current application. I'm trying to move it from one to another, and
since CommandBar belongs to Office (as opposed to Application or some
useful between-db library), you can't automate it or anything.

Sky wrote:
You could start with something like below.
- Steve

' Copy a command bar or toolbar to a new one
' Example: CommandBarCopy "Form View", "tbrFormViewNew "

<snip>

Jan 21 '06 #9
Haven't tried this myself, but have you seen this?:

http://smsconsulting.spb.ru/shamil_s...s/copycmdb.htm

--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conrad...essjunkie.html
http://www.access.qbuilt.com/html/articles.html
"downwitch" wrote in message:
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
Thanks Steve, but that actually only copies a command bar within the
current application. I'm trying to move it from one to another, and
since CommandBar belongs to Office (as opposed to Application or some
useful between-db library), you can't automate it or anything.


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jan 21 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2551
by: Lex | last post by:
I am writing a C# app that has a Menu. Some of the menu items will have short cuts that do not exist in the Shortcut enum. I would like the custom shortcuts to appear on the menu but as far as I can tell there is no way to add a short cut that is not in the Shortcut enum. I have my on keyboard hook so I am not worried about the custom shortcut magically working. I just want it to appear nicely formated on the menu. Anyone have any...
2
6518
by: Larry R Harrison Jr | last post by:
I have Access 97. I know how to create custom command bars. I typically create pull-down menus; seldom do I create toolbars. But I have a case where I would; in fact, I would like to have a menu bar AND a toolbar, BOTH types of command bars for this form. But in the PROPERTIES of this form it doesn't allow but one at the time apparently. Anyway around this?
4
8840
by: Salad | last post by:
A97. If you set a forms properties to ShortcutMenu = No, the entire form is disabled from displaying a shortcut menu. If you set the property to Yes, all controls have a shortcut menu. I have a form that I would like a shortcut menu on 1 control and no shortcut on any other control in the form. But the controls that have no shortcut display a default shortcut. Access help states " If you set the ShortcutMenuBar property to a value
7
1713
by: Ian Hinson | last post by:
I have an Access app that has been distributed with run-time installation to many different customers over many years. It is developed in Access 2000. The custom menu bar has had no problems in the past. However on one new computer it was installed on last week the custom 'Tools' menu (which normally contains items such as 'Backup Data' and 'Preferences..' etc) has been replaced by a single menu item under Tools that says 'Other..'....
27
45527
by: Wayne | last post by:
I've been clicking around Access 2007 Beta 2 and can't see the custom menu bar designer. Is it in the beta? Maybe I'm blind. The question that comes to mind is: Will custom menu bars be the same height as they were in previous versions or will they be the "ribbon" style that takes up a huge portion of the screen? Also when I use Access 2007 to open an Access 2003 database that has custom menu bars they display as they did in Access...
1
3018
by: rdemyan via AccessMonster.com | last post by:
I have custom menu bars for Admins and Users. I now need to add a new group call 'DataEntry'. Their custom menu bar will be very similar to that for Admins, with just a few items removed. So, is there a way to copy a custom menu bar and give it a different name. The current Admin menu bar has a large number of items. To recreate it would probably take several hours. So if I could copy it, give it a different name and then remove...
0
7955
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8251
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5839
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5418
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3873
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2391
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1490
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.