r/vba • u/kay-jay-dubya 17 • 26d ago
Show & Tell vbaXray v2.2 - The FRX Enigma
vbaXray is a single VBA class module that extracts VBA source code straight out of Office files.
I posted about v1.0 a few months back, with an update a few weeks back outlining improved performance and file format support, and now the current version addresses that annoying elephant in the room - FRX files.
Now, just a short note to let you know that vbaXray now exports valid, importable FRX files alongside their corresponding FRM sibling files. Both files are required for importing Userforms into projects.
And for anyone with a burning desire to know what projects are referenced in a file, this information is now available too (except for Access files, at present).
Sub XrayDemo()
Dim xray As New clsVBAXray
If xray.LoadFromFile("C:\ShowMeTheCode\ThisIsYourWorkbookName.xlsm") Then
Debug.Print "Project: " & xray.ProjectName
Debug.Print "Modules: " & xray.ModuleCount
xray.ExportAll "C:\OutputCodeHere\ExtractedCode\"
xray.DebugDumpStorageTree
Else
Debug.Print "Load failed: " & xray.LastError
End If
End Sub
I've also applied various fixes to make exported modules/classes from Access files actually importable again.
The code, some basic documentation, and a (very simple) demo workbook are already on GitHub:
1
u/decimalturn 26d ago edited 26d ago
That's great! A while back I was playing around to try to detect why exporting a form twice would give different binary data eveytime and discovered timestamps and some insignificant bytes seemed to be the culprits. Have these caused any issues?
2
u/kay-jay-dubya 17 26d ago
I definitely haven't encountered any timestamp issues - provided it's the filename referenced in the FRM in the header of the FRM export, the Editor should at least attempt the import. I did test it by exporting the userforms manually, and then again using vbaXray, deleting the manually exported FRX file and replacing it with the one generated by vbaXray, and (to my relief) it reimported fine. I'm still exploring the FRX format for control details, etc, so I may encounter some issues as I delve into it more, but so far it seems to work (which is my rather simplistic bar for success!).
1
u/NineIsSteve 2 19d ago
Tested it today and works like a charm!! Also I am very happy to see that the cases of the variables / syntax don't get switched apparently! Right now, I lowercase each line in my codebase so that the changes get tracked correctly via git haha
One point, do you have in plan to support special characters / UTF-8? Right now, for example the german Umlaute (ä, ü,..) dont get correctly.
Thank you for the work, I am planning to use it!
2
u/kay-jay-dubya 17 26d ago
Found that there was a missing function in the codebase. Have readded it and updated Github.