Neither situation applies to the CommandBars-related objects and methods of the Office Object Library that we will be using. This code should safely run in all supported versions of Microsoft Access. In Access 2003 and earlier, you could create custom command bars through the user interface. With the introduction of the ribbon in Access 2007, that feature was removed from the development user interface. But the feature itself still remained, lurking in the shadows. A Brief Note About Built-in Command Bars There are hundreds of built-in command bars. For these shortcut menus, I advise you to avoid them entirely and create completely new command bars instead. The safest way to avoid naming collisions with the existing command bars is to use a two- or three-character prefix as part of the cmmand bar name. The CommandBars are stored in a collection. There is no "Exists" function we can call to see if a certain command bar has already been created. Before you create a custom command bar, you should run a quick check to make sure it does not already exist as a built-in command bar (see note above). To do this, pass the proposed name of your shortcut menu to the CommandBars collection and try to return its. The goal here is to receive the error message shown in the screenshot above: Run-time error '5': Name property in the Immediate window: "Edit" is the name of a built-in command bar, but if I prefix it with "nls" I get Error 5 which basically says the command bar does not exist. This tells us that the command bar name we want to use is not already taken by a built-in command bar. The safest way to make modifications to a command bar is to build it from scratch every time. To make that easier, I wrote a short helper function. This function attempts to delete the command bar in case it already exists. Private Function ResetCustomBar(BarName As String) As Office.CommandBar It then creates a new–empty–command bar that we will populate in a different method. Set ResetCustomBar = CommandBars.Add(BarName, msoBarPopup, False)Įnd Function Creating the Actual Menu Barįinally, we get to the code where we create the actual menu bar. ![]() Here's the exact code I used in the right-click menu shown in the animated gif above: Sub BuildStatusUpdateCmdBar() I recommend that you maintain a separate procedure for each shortcut menu bar that you create. The nice thing about this approach is that whenever you want to add, remove, or rearrange buttons in the shortcut menu, you just update the above Sub routine, re-run it, and you're done! (It's also very version-control friendly.) Set Bar = ResetCustomBar("ppStatusUpdateCmdBar")ĭebug.Print "Command bar " Bar.Name " updated" #SHORTCUT MENU BAR ACCESS 2013 CODE# ![]() / a solid blueish background and then fades everything out.To create a simple right-click menu, though, you really only need two: There are lots of other CommandBar Control properties and methods you can play around with. / "Draws" the cloud by make its stroke line gradually visible, then shows The most important part starts at line 144: /// Animates the cloud up and down.ĬustomUIRefreshControl.addRefreshUpDownAnimation() ![]() QuartzCode = timesaving.Īnd here is the Github project (with the QuartzCode file).ĭon't mind all the boilerplate code in that TableViewController. Here are some very simple examples on creating custom UIRefreshControl elements with QuartzCode: While PaintCode focus more on "static" images (although you can also use it to create nice little animations), QuartzCode provides a powerful canvas to build almost any type of composition. It's pretty good! I use it regularly at my workplace + PaintCode ( really good too).
0 Comments
Leave a Reply. |