top of page

Sometimes, it's just the little things - #10: Better Bookmarks in VBA

John

VBE_Extras adds a whole load of functionality (see What is VBE_Extras) to the standard VBE. But sometimes, rather than the major areas of functionality, it's just the little things that it does that make me smile. Here's an example.


Don't you just love the built-in 'Bookmarks' functionality within the VBE? No? Me neither. Absolutely useless:



A VBE_Extras user asked me if VBE_Extras has specific Bookmarks functionality. It doesn't is the quick answer. However, you can use the existing Tasks functionality to act as Bookmarks.


First, you need to set things up (you need do this only once):


  • Go to the 'Task Items' tab in the VBE_Extras 'Settings'

  • Click in the whitespace below the existing listed Task Items and a dialog to ‘Enter text for new Task Item’ will appear

  • Enter a name … e.g. BOOKMARK

  • Optionally, set a different priority and maybe make it not case sensitive … but ensure Active is True


... so you will have something like this ...

Adding a "Bookmark" Task Item

... then close the Settings dialog.


To add a Bookmark in your code, then:


  • Wherever you want the Bookmark to be, add a code-comment (i.e. apostrophe) followed by the name you entered for the new Task Item (e.g. BOOKMARK in this example) followed by any text you want to use to describe the reason for the Bookmark e.g. you might use: ‘BOOKMARK: Hello World!

  • You can add as many Bookmarks as you want

  • Use the ‘Tasks in this Project’ menu item (or Ctrl + Shift + T if using the default VBE_Extras keyboard shortcuts) and your Bookmarks will be listed in the ‘Tasks dialog‘ (showing exactly where the Bookmark is within your Project, and showing the text you added to describe the Bookmark) … along with any other Tasks you have added to your code

  • If you want to see only your Bookmarks (instead of also seeing any other types of Task Items), then in the ‘filter box’ at the top of the ‘Tasks dialog’, type the name you entered as the new Task Item (e.g. BOOKMARK ... or bookmark ... it's not case sensitive)


... like this ...


List of Bookmarks

To go to the location of a Bookmark, in the ‘Tasks dialog’, you can then select the Bookmark and click on the Goto button.


As the Bookmark is just a code comment, when you save your VBA Project, the Bookmark will be saved with it.


Improving the built-in Bookmarks functionality


You can actually see all of the Bookmarks and jump to any one of them using VBE_Extras ... use Extras > Goto > Bookmark in this Project ... you will then get a drop-down with a list of all Bookmarks and you can select any one of them to jump to it. I strongly suggest that you don't bother though ... use the VBE_Extras Tasks functionality instead!



Comments


bottom of page