Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old January 19th, 2006, 10:55 PM
downwitch
Guest
 
Posts: n/a
Default Programmatically 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.

  #2  
Old January 20th, 2006, 01:55 AM
salad
Guest
 
Posts: n/a
Default Re: Programmatically copy custom shortcut menu bars (command bars)?

downwitch wrote:
[color=blue]
> 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.
>[/color]
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.
  #3  
Old January 20th, 2006, 02:15 AM
downwitch
Guest
 
Posts: n/a
Default Re: Programmatically copy custom shortcut menu bars (command bars)?

Thanks, but I think MSysCmdbars disappeared after 97. In any case,
it's no longer visible, even with system tables visible.

  #4  
Old January 20th, 2006, 03:55 AM
Lyle Fairfield
Guest
 
Posts: n/a
Default Re: Programmatically copy custom shortcut menu bars (command bars)?

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:\Documents and Settings\Lyle Fairfield\My
Documents\Access\northwind.mdb", _
"NorthwindCustomMenuBar"
End Sub

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

On Error Resume Next

bConfirmActionQueries = GetOption("Confirm Action Queries")
If bConfirmActionQueries Then SetOption "Confirm Action Queries",
False

With DBEngine(0)(0)

Err = 0
.TableDefs("MSysCmdBars").Name = .TableDefs("MSysCmdBars").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(MenuNames) = -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.Refresh
Set rst = .TableDefs("MSysCmdBars").OpenRecordset
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 bConfirmActionQueries Then SetOption "Confirm Action Queries",
True

End Sub

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

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

  #5  
Old January 20th, 2006, 06:35 PM
downwitch
Guest
 
Posts: n/a
Default Re: Programmatically copy custom shortcut menu bars (command bars)?

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?

  #6  
Old January 20th, 2006, 07:15 PM
Lyle Fairfield
Guest
 
Posts: n/a
Default Re: Programmatically copy custom shortcut menu bars (command bars)?

Wizhook was definitely in AC2K. Peter Walker was the first to post
about it shortly after AC2K was shipped. I can verify that
(.WizCopyCmdBars) exists and works in Ac2002 and Ac2003. It seems then
that it's missing from AC2K; arrrrrrrgggggggghhhhhh.
****
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.

  #7  
Old January 20th, 2006, 08:45 PM
Sky
Guest
 
Posts: n/a
Default Re: Programmatically copy custom shortcut menu bars (command bars)?


"downwitch" <downwitch@gmail.com> wrote in message
news:1137781479.528210.316520@g47g2000cwa.googlegr oups.com...[color=blue]
>
> Any other ideas?
>[/color]

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 CommandBarControl
On Error GoTo Problem
Set cbrNew = CommandBars.Add(strCbrNewName)
cbrNew.Visible = True
For Each ctl In CommandBars(strCbrOrigName).Controls
ctl.Copy cbrNew
Next ctl
Set ctl = Nothing
Set cbrNew = Nothing
Exit Function
Problem:
MsgBox Err.Description, vbCritical, "CommandBarCopy Error"
End Function




  #8  
Old January 21st, 2006, 12:05 AM
downwitch
Guest
 
Posts: n/a
Default Re: Programmatically copy custom shortcut menu bars (command bars)?

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:[color=blue]
> Wizhook was definitely in AC2K. Peter Walker was the first to post
> about it shortly after AC2K was shipped. I can verify that
> (.WizCopyCmdBars) exists and works in Ac2002 and Ac2003. It seems then
> that it's missing from AC2K; arrrrrrrgggggggghhhhhh.
> ****
> 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.[/color]

  #9  
Old January 21st, 2006, 12:05 AM
downwitch
Guest
 
Posts: n/a
Default Re: Programmatically copy custom shortcut menu bars (command bars)?

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:
[color=blue]
> You could start with something like below.
> - Steve
>
> ' Copy a command bar or toolbar to a new one
> ' Example: CommandBarCopy "Form View", "tbrFormViewNew"[/color]
<snip>

  #10  
Old January 21st, 2006, 02:45 AM
Jeff Conrad
Guest
 
Posts: n/a
Default Re: Programmatically copy custom shortcut menu bars (command bars)?

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:1137801101.264472.125820@g44g2000cwa.googlegr oups.com...
[color=blue]
> 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.[/color]



----== 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 =----
  #11  
Old January 25th, 2006, 07:15 PM
downwitch
Guest
 
Posts: n/a
Default Re: Programmatically copy custom shortcut menu bars (command bars)?

Huh, that mostly works. Meaning CommandBars *does* belong to
Application, even if it doesn't expose that way. Shoulda tried that
first I guess, rather than believing the object browser and CTL+SPACE.

Now I just need to figure out how to copy images (that code doesn't
seem to...) and I'll be set. Thanks to all who pitched in.


Jeff Conrad wrote:[color=blue]
> 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[/color]

  #12  
Old January 25th, 2006, 08:28 PM
downwitch
Guest
 
Posts: n/a
Default Re: Programmatically copy custom shortcut menu bars (command bars)?

Follow-up: how to copy "button image" from one commandbarcontrol to
another:

Sub uCommandBarCtl_CopyImage(pctlCbrSource As CommandBarControl, _
pctlCbrNew As CommandBarControl)
On Error Resume Next

'get commandbar button image (custom or built-in) and paste
pctlCbrSource.CopyFace
pctlCbrNew.PasteFace

End Sub

  #13  
Old January 26th, 2006, 03:35 AM
Jeff Conrad
Guest
 
Posts: n/a
Default Re: Programmatically copy custom shortcut menu bars (command bars)?

Thanks for the update and additional code sample.

--
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:1138219915.971604.51120@z14g2000cwz.googlegro ups.com...
[color=blue]
> Follow-up: how to copy "button image" from one commandbarcontrol to
> another:
>
> Sub uCommandBarCtl_CopyImage(pctlCbrSource As CommandBarControl, _
> pctlCbrNew As CommandBarControl)
> On Error Resume Next
>
> 'get commandbar button image (custom or built-in) and paste
> pctlCbrSource.CopyFace
> pctlCbrNew.PasteFace
>
> End Sub[/color]



----== 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 =----
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles