Adding AI generated UserForms to your VBA Project (using .frxml files)
- John
- 16 hours ago
- 7 min read
A frustration that I have with using AI to support me in writing VBA code is generating UserForms ... specifically the user interface (UI) part of UserForms. A UserForm's UI (such as the Controls the UserForm displays, their locations, sizes, colours, behaviours etc) is contained in a .frx file which is a binary file (unlike the .frm text file that contains the code of the UserForm). Not only is a binary file much more challenging for AI to create, the specification of that file is not publicly available (it is also time-bound - the actual binary data varies over time for an identical UI - if you save an identical UserForm twice, the two .frx files will not be byte-for-byte identical).
So typically what happens is one of:
The AI builds the UserForm for you using COM. What's the problem with this? Error prone. Slow. Uses many tokens compared to the alternatives. Requires you to check "Trust access to the VBA project object model" which is a security risk (and is blocked in many centrally-controlled IT environments).
The AI provides you the code in a .frm and a series of instructions on how to manually build the UI ... adding various controls, naming them, setting their locations, sizing them, setting various other properties. What's the problem with this? It takes ages and it's error prone. And tedious. And when you want to change the UserForm's UI then you have to do it all over again.
The AI provides you the code in a .frm and that code programmatically builds the UI (adding the Controls, naming them, setting their locations, sizing them, setting various other properties) during the initialisation of the UserForm ... you add a blank UserForm and paste the code into the UserForms code-behind and the UI is built programmatically at the point it is shown. What's the problem with this? The VBA code is overly complex (each Control requiring many lines to set its properties plus various WithEvents lines to handle events) and difficult to maintain. For large and complex UserForms, there can be a noticeable lag while the UserForm is drawn part-by-part. You also cannot view the UI without running the code ... I often find I want to tweak the initial layout which is challenging when it is built programmatically.
And for the latter two, an AI agent will you provide you with a .frm file ... because there is no associated .frx file then using the VBE's "Import File" command will result in a standard Module being added and not a UserForm. So, again, you have two options:
Import the UserForm as a standard Module ... then add the UserForm yourself, resize it and copy the code across. Then remove the standard Module.
Add a UserForm and rename it to the same name as the .frm file uses. Export the UserForm which gives you a .frm file and a .frx file representing a blank UserForm. Delete the .frm file and then copy the .frx file into the same folder as the .frm file that the AI agent created for you. Then you can import the UserForm as an actual UserForm.
Messy. Clunky. Error-prone. So how about an alternative? That's what a .frxml file is.
Why .frxml ... it's a combination of .frx (obviously) and XML ... and it's a way for an AI agent to describe the UI of a UserForm in XML. You can then use the .frxml file alongside a .frm file and load the UserForm (both code and UI) directly.
But first ... there's a couple of things you need to make this work.
Using a skill to teach an AI agent to generate a .frxml file
A skill, in AI terms, is a standardised way to give AI agents new capabilities and expertise.
It consists of a file (or sometimes more than one file ... but in this case, just one file) in a folder. The core file in any skill is a SKILL.md file which includes metadata and instructions that tell an agent when and how to perform a specific task. One of the key aspects of skills is that they are an open standard ... originally developed by Anthropic ... and you can re-use them across many different AI agents ... whether you're using Claude (like me ... for the moment at least!), Gemini, Codex or many others.
To read more about skills, see the Agent Skills open standard or the Anthropic introduction to AI skills Equipping agents for the real world with Agent Skills.
And here is a link to the vbe-userform-files web page at which you can download the skill which will allow you to give your AI agent the ability to generate .frxml (and, of course, .frm) files.
Once you have downloaded the file from that web page, unzip it. It consists of a single vbe-userform-files.skill file (which is, itself, actually just a zipped folder containing a single markdown file ... if you change the file extension from .skill to .zip then you can unzip it and find the md file inside).
If you happen to be using the Claude desktop application, like me, then you install a skill by clicking on "Customize" (or "Settings") then "Skills" then there is an "Add" dropdown within which select the "Upload a skill" option ... you can then drag-and-drop the skill file or use the file-select dialog to locate it (these instructions are correct for the Claude desktop application as of July 2026). Obviously every other AI tool is going to use a slightly different process for installing a skill and I'm not going to try to describe that process for every AI tool. But skills are an open standard supported by many AI agents so the documentation for your AI tool should outline how to do this.
Once you've done that, your AI tool will then be aware of the "vbe-userform-files" skill and can use it to create .frxml (and .frm) files. Try it out ... depending on your AI tool of choice, you may need to explicitly call the skill into scope (eg using a "slash command" such as /vbe-userform-files) or your AI tool may automatically use the skill when you ask it to create a UserForm.
If you're not sure what to ask for, here's an example prompt that you can copy and paste into your AI tool:
Create a VBA UserForm that includes a ComboBox and 2 Buttons (Cancel and OK) ... the UserForm allows an array of Strings to be passed in which are shown in the ComboBox; the user can select any one of them and click OK or Cancel; calling code should be able to obtain the selected String and whether OK or Cancel were clicked. Strings will always be less than or equal to 24 characters in length.
... this doesn't explicitly call the vbe-userform-files skill into scope so if you find your AI struggles with creating the .frxml file then read the documentation for your AI agent and call the skill into scope explicitly.
In case you're interested in what a .frxml file looks like, here's an example that was created by an AI agent following the above prompt:
... obviously your AI tool is unlikely to create something identical ... but it should be similar.
Creating a UserForm from a .frxml file
So that's all well-and-good, but all you've got so far is a .frxml (and .frm) file ... not a UserForm.
To create the UserForm, you need VBE_Extras (release 1.7.4.0 or newer). With a VBA Project open in the VBE, in the Project window, right-click on either:
The Project name and then select Extras > Load from / save as files > Load new Module, or
Any existing Module and then select Extras > Load from / save as files > Load new Module
... then, in the file-select dialog, navigate to and select the folder containing the .frm and .frxml files and then VBE_Extras will walk you through the process of loading the UserForm from the files.
Note that there is also a "Load this Module" menu item (available when you right-click on an existing Module) which you can use if you are have a UserForm and want to update it (if, say, you've had the AI tool revise the UserForm design and so you have updated files to load to your VBA Project).
There is also an option to right-click on a Project name and select Extras > Load from / save as files > Load Project from files and you can load an entire VBA Project from files if, say, you've had your AI tool create an entire Project in one go (note that this command loads VBA code and attributes and UI elements of UserForms and, if working in Access, Forms and Reports ... it won't load, for example, updated RibbonX code or, if working in Access, tables, queries, macros).
For more on loading a UserForm (or any type of Module) or an entire Project's worth of Modules including the "diff report" that you will be shown, see the Syncing a VBA Project with a file(s) ... manually post.
So ... no more tedious and / or error prone process and / or no more having to switch on settings that pose a security risk. Get your AI tool to create a UserForm with a .frxml file. Import it into your VBA Project using VBE_Extras. Simple.
But are there any limitations that come with using a .frxml file?
Yes, there are. And your AI agent will be aware of these limitations as they are captured in the skill, and will help you to work around them wherever possible. The limitations are:
Works only with specific Controls ... initially, it works with:
All 14 built-in MSForms Controls: Label, TextBox, ComboBox, ListBox, CheckBox, OptionButton, ToggleButton, CommandButton, ScrollBar, SpinButton, Image, TabStrip, Frame and MultiPage. And, for clarity, it allows Controls to be embedded within the other types of Control that are designed as containers.
8 ActiveX Controls: RefEdit, DateTimePicker, MonthView, ProgressBar, ListView, TreeView, Slider, and ImageList. Obviously the ActiveX Controls also need to be installed on your machine ... not all machines have all ActiveX Controls.
Does not support the Picture property of the UserForm itself or of other Controls that have a Picture property (notable the Image Control) ... this is because the Picture property expects binary data (an actual picture) whereas an .frxml file is text (that's kinda the point of it!) ... the workaround is to have your VBA code (in the .frm file) add the picture at runtime.
Does not support the MouseIcon property of the UserForm and the other Controls that have a MouseIcon property ... for the same reason as the Picture property and with the same workaround.
The Value property of the ProgressBar ActiveX Control ... this property cannot be set at design time ... the workaround is to set at runtime.
The BackColor, ForeColor and HoverSelection properties of the TreeView ActiveX Control ... for the same reason as the Value property of the ProgressBar Control and with the same workaround.
For more details on the skill, the .frxml file and the VBE_Extras functionality, see the VBE_Extras user guide appendix 9.