Copy VBA code in colour
- John
- 1 day ago
- 2 min read
VBE_Extras will now let you copy code direct from the VBE 'in colour' ... and using a specific font name and size. How does it do this? Actually, what it does is copy the code as HTML (with some CSS for styling). So instead of copy/paste resulting in such as this ...
... it results in this ...
This works not only in web pages and blog posts but also in Word documents, emails etc ... anywhere into which you can paste 'as HTML'.
However, when used in web pages and blog posts, some JavaScript can be included with the HTML and CSS to add a 'Copy code' button like this (click it to test!) ...
Its also possible to customise the style of the code using a file containing CSS style definitions ...
And its also possible to customise the style of the button using another file containing CSS style definitions ...
And you can change the text used for the button ...
Or even use Unicode characters to make it appear to contain an icon ...
This new functionality of VBE_Extras is called 'Copy as HTML' and you'll find it in the 'Other tools' section of the VBE_Extras menu. In this post, I'm deliberately not going into the detail of how to use 'Copy as HTML' though to get the basic colours, font and button is (I like to think!) fairly straight-forward and can be done directly from the 'Copy as HTML' dialog ...

However, to understand how to use files with CSS to further customise the style of the code and the button, and how to use files to customise the text on the button, please see the section of the same name in the VBE_Extras user guide.
Special thanks to Colin Riddington for testing (and re-testing ... !) this functionality ... if you develop VBA code in Access and you haven't checked-out Colin's website previously, please do so now at https://isladogs.co.uk/about-us/index.html.