{"id":14070852,"url":"https://github.com/sancarn/stdVBA","last_synced_at":"2025-07-30T08:33:15.342Z","repository":{"id":47580840,"uuid":"164031037","full_name":"sancarn/stdVBA","owner":"sancarn","description":"VBA Standard Library - A Collection of libraries to form a common standard layer for modern VBA applications.","archived":false,"fork":false,"pushed_at":"2024-05-28T01:32:50.000Z","size":9370,"stargazers_count":264,"open_issues_count":34,"forks_count":57,"subscribers_count":27,"default_branch":"master","last_synced_at":"2024-05-29T04:56:21.449Z","etag":null,"topics":["macros","microsoft","microsoft-excel","vba","vba-library"],"latest_commit_sha":null,"homepage":"","language":"VBA","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sancarn.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-03T22:52:36.000Z","updated_at":"2024-05-28T01:32:53.000Z","dependencies_parsed_at":"2023-10-04T07:24:50.356Z","dependency_job_id":"085aec8c-c3e3-4683-b273-986625e53414","html_url":"https://github.com/sancarn/stdVBA","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sancarn%2FstdVBA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sancarn%2FstdVBA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sancarn%2FstdVBA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sancarn%2FstdVBA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sancarn","download_url":"https://codeload.github.com/sancarn/stdVBA/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":215155197,"owners_count":15836926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["macros","microsoft","microsoft-excel","vba","vba-library"],"created_at":"2024-08-13T07:08:07.996Z","updated_at":"2025-07-30T08:33:15.320Z","avatar_url":"https://github.com/sancarn.png","language":"VBA","funding_links":[],"categories":["VBA"],"sub_categories":[],"readme":"# stdVBA\n\nA Collection of libraries to form a common standard layer for modern VBA applications.\n\n## Benefits\n\n* Code faster!\n* Improve code maintainability.\n* Let the library handle the complicated stuff, you focus on the process \n* Heavily inspired by JavaScript APIs - More standard\n* Open Source - Means the libraries are continually maintained by the community. Want something added, help us make it!\n\n[The full roadmap](https://github.com/sancarn/stdVBA/projects/1) has more detailed information than here.\n\n## Getting started\n\n[A video series](https://www.youtube.com/watch?v=IJ8PNiqnuMU\u0026list=PLfpJqtusLMmotZqzFtZ6FCPRin5N_BjPA) is being created to demonstrate how to get started with stdVBA. Alternatively there is a small getting started document [in the discussions](https://github.com/sancarn/stdVBA/discussions/30)\n\n## Short example\n\nPlease visit [the examples repository](https://github.com/sancarn/stdVBA-examples) for more fully featured applications/examples using this library.\n```vb\nsub Main()\n  'Create an array\n  Dim arr as stdArray\n  set arr = stdArray.Create(1,2,3,4,5,6,7,8,9,10) 'Can also call CreateFromArray\n\n  'Demonstrating join, join will be used in most of the below functions\n  Debug.Print arr.join()                                                 '1,2,3,4,5,6,7,8,9,10\n  Debug.Print arr.join(\"|\")                                              '1|2|3|4|5|6|7|8|9|10\n\n  'Basic operations\n  arr.push 3\n  Debug.Print arr.join()                                                 '1,2,3,4,5,6,7,8,9,10,3\n  Debug.Print arr.pop()                                                  '3\n  Debug.Print arr.join()                                                 '1,2,3,4,5,6,7,8,9,10\n  Debug.Print arr.concat(stdArray.Create(11,12,13)).join                 '1,2,3,4,5,6,7,8,9,10,11,12,13\n  Debug.Print arr.join()                                                 '1,2,3,4,5,6,7,8,9,10 'concat doesn't mutate object\n  Debug.Print arr.includes(3)                                            'True\n  Debug.Print arr.includes(34)                                           'False\n\n  'More advanced behaviour when including callbacks! And VBA Lamdas!!\n  Debug.Print arr.Map(stdLambda.Create(\"$1+1\")).join          '2,3,4,5,6,7,8,9,10,11\n  Debug.Print arr.Reduce(stdLambda.Create(\"$1+$2\"))           '55 ' I.E. Calculate the sum\n  Debug.Print arr.Reduce(stdLambda.Create(\"application.worksheetFunction.Max($1,$2)\"))      '10 ' I.E. Calculate the maximum\n  Debug.Print arr.Filter(stdLambda.Create(\"$1\u003e=5\")).join      '5,6,7,8,9,10\n  \n  'Execute property accessors with Lambda syntax\n  Debug.Print arr.Map(stdLambda.Create(\"ThisWorkbook.Sheets($1)\")) _ \n                 .Map(stdLambda.Create(\"$1.Name\")).join(\",\")            'Sheet1,Sheet2,Sheet3,...,Sheet10\n  \n  'Execute methods with lambdas and enumerate over enumeratable collections:\n  Call stdEnumerator.Create(Application.Workbooks).forEach(stdLambda.Create(\"$1.Save\")\n  \n  'We even have if statement!\n  With stdLambda.Create(\"if $1 then \"\"lisa\"\" else \"\"bart\"\"\")\n    Debug.Print .Run(true)                                              'lisa\n    Debug.Print .Run(false)                                             'bart\n  End With\n  \n  'Execute custom functions\n  Debug.Print arr.Map(stdCallback.CreateFromModule(\"ModuleMain\",\"CalcArea\")).join  '3.14159,12.56636,28.274309999999996,50.26544,78.53975,113.09723999999999,153.93791,201.06176,254.46879,314.159\n\n  'Let's move onto regex:\n  Dim oRegex as stdRegex\n  set oRegex = stdRegex.Create(\"(?\u003ccounty\u003e[A-Z])-(?\u003ccity\u003e\\d+)-(?\u003cstreet\u003e\\d+)\",\"i\")\n\n  Dim oRegResult as object\n  set oRegResult = oRegex.Match(\"D-040-1425\")\n  Debug.Print oRegResult(\"county\") 'D\n  Debug.Print oRegResult(\"city\")   '040\n  \n  'And getting all the matches....\n  Dim sHaystack as string: sHaystack = \"D-040-1425;D-029-0055;A-100-1351\"\n  Debug.Print stdEnumerator.CreateFromIEnumVARIANT(oRegex.MatchAll(sHaystack)).map(stdLambda.Create(\"$1.item(\"\"county\"\")\")).join 'D,D,A\n  \n  'Dump regex matches to range:\n  '   D,040,040-1425\n  '   D,029,029-0055\n  '   A,100,100-1351\n  Range(\"A3:C6\").value = oRegex.ListArr(sHaystack, Array(\"$county\",\"$city\",\"$city-$street\"))\n  \n  'Copy some data to the clipboard:\n  Range(\"A1\").value = \"Hello there\"\n  Range(\"A1\").copy\n  Debug.Print stdClipboard.Text 'Hello there\n  stdClipboard.Text = \"Hello world\"\n  Debug.Print stdClipboard.Text 'Hello world\n\n  'Copy files to the clipboard.\n  Dim files as collection\n  set files = new collection\n  files.add \"C:\\File1.txt\"\n  files.add \"C:\\File2.txt\"\n  set stdClipboard.files = files\n\n  'Save a chart as a file\n  Sheets(\"Sheet1\").ChartObjects(1).copy\n  Call stdClipboard.Picture.saveAsFile(\"C:\\test.bmp\",false,null) 'Use IPicture interface to save to disk as image\nEnd Sub\n\nPublic Function CalcArea(ByVal radius as Double) as Double\n  CalcArea = 3.14159*radius*radius\nEnd Function\n```\n\n## Motivation\n\nVBA first appeared in 1993 (over 25 years ago) and the language's age is definitely noticable. VBA has a lot of specific libraries for controlling Word, Excel, Powerpoint etc. However the language massively lacks in generic modern libraries for accomplishing common programming tasks. VBA projects ultimately become a mish mash of many different technologies and programming styles. Commonly for me that means calls to Win32 DLLs, COM libraries via late-binding, calls to command line applications and calls to .NET assemblies.\n\nOver time I have been building my own libraries and have gradually built my own layer above the simple VBA APIs.\n\nThe VBA Standard Library aims to give users a set of common libraries, maintained by the community, which aid in the building of VBA Applications.\n\n## Road Map\n\nThis project is has been majorly maintained by 1 person, so progress is generally very slow. This said, generally the road map corresponds with what I need at the time, or what irritates me. In general this means `fundamental` features are more likely to be complete first, more complex features will be integrated towards the end. This is not a rule, i.e. `stdSharepoint` is mostly complete without implementation of `stdXML` which it'd use. But as a general rule of thumb things will be implemented in the following order:\n\n* Types - `stdArray`, `stdDictionary`, `stdRegex`, `stdDate`, `stdLambda`, ... \n* Data  - `stdJSON`, `stdXML`, `stdOXML`, `stdCSON`, `stdIni`, `stdZip` \n* File  - `stdShell` \n* Automation - `stdHTTP`, `stdAcc`, `stdWindow`, `stdKernel`\n* Excel specific - `xlFileWatcher`, `xlProjectBuilder`, `xlTimer`, `xlShapeEvents`, `xlTable`\n* Runtimes - `stdCLR`, `stdPowershell`, `stdJavascript`, `stdOfficeJSBridge`\n\nAs an indicator of where my focuses have been in the past year, take a look at the following heat map:\n\n![changesHeatMap](./docs/assets/changesHeatMap.png)\n\n## Planned Global Objects:\n\n\u003c!--\n  docs/assets/Status_G.png - Ready\n  docs/assets/Status_Y.png - WIP\n  docs/assets/Status_R.png - Hold\n--\u003e\n\n\n|Color                                                     | Status | Type       |Name             |Docs | Description  |\n|----------------------------------------------------------|--------|------------|-----------------|-----|--------------|\n|![l](docs/assets/Status_R.png) | HOLD   | Debug       |stdError        | None | Better error handling, including stack trace and error handling diversion and events.\n|![l](docs/assets/Status_G.png) | READY  | Type        |stdArray        | None | A library designed to re-create the Javascript dynamic array object.\n|![l](docs/assets/Status_G.png) | READY  | Type        |stdEnumerator   | [docs](docs/stdEnumerator.md) | A library designed to wrap enumerable objects providing additional functionality.\n|![l](docs/assets/Status_Y.png) | WIP    | Type        |stdDictionary   | None | A drop in replacement for VBScript's dictionary.\n|![l](docs/assets/Status_G.png) | READY  | Type        |stdDate         | None | A standard date parsing library. No more will you have to rely on Excel's interpreter. State the format, get the data.\n|![l](docs/assets/Status_G.png) | READY  | Type        |stdRegex        | None | A regex library with more features than standard e.g. named capture groups and free-spaces.\n|![l](docs/assets/Status_G.png) | READY  | Type        |stdLambda       | [docs](docs/stdLambda.md) | Build and create in-line functions. Execute them at a later stage.\n|![l](docs/assets/Status_G.png) | READY  | Type        |stdCallback     | None | Link to existing functions defined in VBA code, call them at a later stage.\n|![l](docs/assets/Status_G.png) | READY  | Type        |stdCOM          | None | A wrapper around a COM object which provides Reflection (through ITypeInfo), Interface querying, Calling interface methods (via DispID) and more. \n|![l](docs/assets/Status_G.png) | READY  | Automation  |stdClipboard    | None | Clipboard management library. Set text, files, images and more to the clipboard.\n|![l](docs/assets/Status_R.png) | HOLD   | Automation  |stdHTTP         | None | A wrapper around Win HTTP libraries.\n|![l](docs/assets/Status_G.png) | READY  | Automation  |stdWindow       | [docs](docs/stdWindow.md) | A handy wrapper around Win32 Window management APIs.\n|![l](docs/assets/Status_G.png) | READY  | Automation  |stdProcess      | None | Create and manage processes.\n|![l](docs/assets/Status_G.png) | READY  | Automation  |stdAcc          | [docs](docs/stdAcc.md) | Use Microsoft Active Accessibility framework within VBA - Very useful for automation.\n|![l](docs/assets/Status_G.png) | READY  | Automation  |stdWebSocket    | None | WebSocket automation. Currently uses IE, need to move to more stable runtime. Will be useful for modern automation e.g. chrome\n|![l](docs/assets/Status_Y.png) | WIP    | Excel       |xlTable         | None | Better tables for VBA, e.g. Map rows etc.\n|![l](docs/assets/Status_G.png) | READY  | DevTools    |stdPerformance  | None | Performance testing\n\n[The full roadmap](https://github.com/sancarn/stdVBA/projects/1) has more detailed information than here.\n\n### Statuses\n\n#### ![_](docs/assets/Status_G.png) READY\n\nAPIs which are ready to use, and although are not fully featured are in a good enough working state.\n\n#### ![_](docs/assets/Status_Y.png) WIP\n\nAPIs which are WIP are not necessarily being worked on currently but at least are recognised for their importance to the library. These will be lightly worked on/thought about continuously even if no commits are made.\n\nAs of Oct 2020, this status typically consists of:\n* data types, e.g. stdEnumerator, stdDictionary, stdTable;\n* Unit testing; \n* Tasks difficult to automate otherwise e.g. stdClipboard, stdAccessibility;\n\n#### ![_](docs/assets/Status_R.png) HOLD\n\nAPIs where progress has been temporarily halted, and/or is currently not a priority.\n\nIn the early days we'll see this more with things which do already have existing work arounds and are not critical, so projects are more likely to fit into this category.\n\n#### ![_](https://via.placeholder.com/15/aaaaaa/000000?text=+) UNK\n\nAPIs which have been indefinitely halted. We aren't sure whether we need these or if they really fit into the project. They are nice to haves but not necessities for the project as current. These ideas may be picked up later. All feature requests will fit into this category initially.\n\n## Structure\n\nAll modules or classes will be prefixed by `std` if they are generic libraries.\n\nApplication specific libraries to be prefixed with `xl`, `wd`, `pp`, `ax` representing their specific application.\n\nCommonly implementations will use the factory class design pattern:\n\n```vb\nClass stdSomeClass\n  Private bInitialised as boolean\n\n  'Creates an object from the given parameters\n  '@constructor\n  Public Function Create(...) As stdSomeClass\n    if not bInitialised then\n      Set Create = New stdSomeClass\n      Call Create.protInit(...)\n    else\n      Call CriticalRaise(\"Constructor called on object not class\")\n    End If\n  End Function\n\n  'Initialises the class. This method is meant for internal use only. Use at your own risk.\n  '@protected\n  Public Sub protInit(...)\n    If bInitialised Then\n      Call CriticalRaise(\"Cannot run protInit() on initialised object\")\n    elseif Me is stdSomeClass then\n      Call CriticalRaise(\"Cannot run protInit() on static class\")\n    else\n      'initialise with params...\n\n      'Make sure bInitialised is set\n      bInitialised=true\n    End If\n  End Sub\n\n  Private Sub CriticalRaise(ByVal sMsg as string)\n    if isObject(stdError) then\n      stdError.Raise sMsg\n    else\n      Err.Raise 1, \"stdSomeClass\", sMsg\n    end if\n  End Sub\n  \n  '...\nEnd Class\n```\n\nWith the above example, the Regex class is constructed with the `Create()` method, which can only be called on the `stdRegex` static class. We will try to keep this structure across all STD VBA classes.\n\n# Contributing\n\nIf you are looking to contribute to the VBA standard library codebase, the best place to start is the [GitHub \"issues\" tab](https://github.com/sancarn/VBA-STD-Library/issues). This is also a great place for filing bug reports and making suggestions for ways in which we can improve the code and documentation. A list of options of different ways to contribute are listed below:\n\n* If you have a Feature Request - Create a new issue\n* If you have found a bug - Create a new issue\n* If you have written some code which you want to contribute - See the Contributing Code section below.\n\n## Contributing Code\n\nThere are several ways to contribute code to the project:\n\n* Opening pull requests is the easiest way to get code intergrated with the standard library.\n* Create a new issue and providing the code in a code block - Bare in mind, it will take us a lot longer to pick this up than a standard pull request.\n\nPlease make sure code contributions follow the following guidelines:\n\n* `stdMyClass.cls` should have `Attribute VB_PredeclaredId = True`. \n* `Attribute VB_Name` should follow the STD convention e.g. `\"stdMyClass\"`\n* Follow the STD constructor convention `stdMyClass.Create(...)`.\n* Ensure there are plenty of comments where required.\n* Ensure lines end in `\\r\\n` and not `\\n` only. You can enable the Git filter in charge of making this automatic conversion by running `git config include.path ../.gitconfig`\n\nAs long as these standard conventions are met, the rest is up to you! Just try to be as general as possible! We're not necessarily looking for optimised code, at the moment we're just looking for code that works!\n\n\u003e Note: Ensure that all code is written by you. If the code is not written by you, you will be responsible for any repercussions!\n\n## Inspiration documents\n\nOver the process of building this library we have drawn from numerous examples and knowledge from across the web. Many of these examples can either be found in our [inspiration library](https://github.com/sancarn/VBA-STD-Lib-Inspiration) or [awesome-vba](https://github.com/sancarn/awesome-vba).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsancarn%2FstdVBA","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsancarn%2FstdVBA","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsancarn%2FstdVBA/lists"}