using code to copy commandbars to another database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to be able to copy commandbars from one MDB to another using code. Is
there a way to do this? I can't find any commands or methods that copy or
transfer commandbars to another database.

If possible, I'd like it to work in Access97, 2000, XP, and 2003.

Here's what I coded; it creates the commandbars, but gives Err 5 when it
tries to copy the controls. ExpObj is the application of the external
database; it works if ExpObj is the same database or I remove "ExpObj." from
the code.

For Each exVal In CommandBars
Debug.Print exVal.Name
Set exVal2 = ExpObj.CommandBars.Add(exVal.Name)
'create new
For Each exCtl In exVal.Controls
exCtl.Copy exVal2 '<THIS GIVES ERR5 IF
exVal2 is from the external database
Next
Next
 
Back
Top