Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Toolbars problem

Status
Not open for further replies.

number2

Technical User
Oct 25, 2001
284
US
I have a problem with custom toolbars. It seems that some of my users do not see the custom toolbars in their runtime distribution of my db. Does anyone have a good grasp of how to make custom toolbars more reliable...so they actually show up on all users distibutions?

Thanks!
 
To avoid issues with toolbars in the past, I decided to build them using code and hide all the default Access ones.

If you search under CommandBar in the VB Help that should get you started. Have not tested under Runtime version though.
 
It seems like a lot of work, but it shouldn't take up more screen real estate, as the toolbars could be replaced by the new hard coded bottons. Do you have any sample code? Some of the more esoteric commands like "Autocorrect, spell check, export to word" may be a bit difficult to hard code??
 
Sure can but tied up at the moment with something else. I will try to build something as a sample over the weekend including some of the examples you gave.
 
Have a look at the following code. You need to set a reference to the MS Office Library else it will not compile.

Function CreateSpecialMenuBar()

Dim MBar As CommandBar
Dim SBar As CommandBarControl

Dim ctl As CommandBarControl

'Test to see if already exists, so delete because we can not create one with the same name
For Each MBar In CommandBars
If MBar.Name = "Test Menu" Then
CommandBars("Test Menu").Delete
End If
Next MBar

'Create the new menu bar
Set MBar = CommandBars.Add("Test Menu", msoBarTop, , True)
MBar.Protection = msoBarNoChangeDock

'Copy the controls I want from the built-in menus
'Must use exactly the same caption as in that menu
Set SBar = CommandBars("Menu Bar").Controls("Window")
SBar.Copy Bar:=MBar

Set SBar = CommandBars("Menu Bar").Controls("Tools").Controls("AutoCorrect Options...")
SBar.Copy Bar:=MBar

Set SBar = CommandBars("Menu Bar").Controls("Tools").Controls("Spelling...")
SBar.Copy Bar:=MBar

'Set how I want it displayed
For Each ctl In CommandBars("Test Menu").Controls
With ctl
If .Type = msoControlButton Then
.style = msoButtonCaption
End If
End With
Next ctl

Set SBar = Nothing

MBar.Visible = True

End Function

You can also create your own menus to do other things so if you want to progress it further, look at the CommandBars help.
 
Thanks for the efforts! Custom Menus do not fuction in Access Runtime. (like so many other valuable functions!)
Half of my time is spent working around these limitations of runtime.
 
Are you getting an error or does the menu just not appear?

Have you created the menu on a full Access machine then opened an application from a runtime machine?
 
Yes, created on full access, and then installed runtime with the db, custom menus do not show up. :((
 
Perhaps the following references might help.

Toolbars
All of the built-in toolbars in Microsoft Access are disabled in a run-time environment. You must create your own custom toolbars for your application if you want to include them.

The run-time environment does not show and hide your custom toolbars as the context changes, so you must manipulate the toolbars in your application by using the ShowToolbar method in the OnActivate and OnDeactivate properties of your forms and reports.

It is from the following article on the MS web site -
ACC2000: Differences Between Retail and Run-Time Microsoft Access

On the workstations where they do not show, what is the difference between these and the ones where they do show?
 
Also

You can control the menus and the commands that are available to users of the Access run-time application. To do this, build the application by using forms that have custom menus. The Access run-time environment does not provide all built-in Access 2003 toolbars and does not support all built-in Access 2003 toolbars. However, you can add your own custom toolbars to the Access run-time application. When you create a custom toolbar, the custom toolbar is stored in the current database of the Access run-time application. Therefore, the custom toolbar is automatically available to the Access run-time application.

therefore it appears that Bill Gates disagrees with your previous statement.
 
Change the following line in your code -

Set MBar = CommandBars.Add("Test Menu", msoBarTop, , True)

by replacing True with False.

This option makes the menu bar temporary and will delete it when you leave the application. Therefore you have run the code in the Access full version and it works, but as soon as you exit it, the menu bar will be deleted so of course it will not be there for the run-time version.

I pulled this code out of an application where temporary menus were created for each user hence my "true" option but you do not want that feature - sorry.

Let me know if that works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top