{"id":18326637,"url":"https://github.com/orhankupusoglu/export-excel-macros","last_synced_at":"2026-04-28T11:01:49.940Z","repository":{"id":230117811,"uuid":"778524773","full_name":"OrhanKupusoglu/export-excel-macros","owner":"OrhanKupusoglu","description":"Filter MS Excel worksheets \u0026 export macros","archived":false,"fork":false,"pushed_at":"2024-04-01T12:45:23.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T16:52:50.410Z","etag":null,"topics":["git","ms-excel","pre-commit-hook","workbook","worksheet"],"latest_commit_sha":null,"homepage":"","language":"Python","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/OrhanKupusoglu.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2024-03-27T22:03:56.000Z","updated_at":"2024-04-01T11:18:51.000Z","dependencies_parsed_at":"2025-04-09T16:41:57.424Z","dependency_job_id":"c5b411ce-75e9-4004-ac9d-e3b9d308c49a","html_url":"https://github.com/OrhanKupusoglu/export-excel-macros","commit_stats":null,"previous_names":["orhankupusoglu/export_excel_macros"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/OrhanKupusoglu/export-excel-macros","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrhanKupusoglu%2Fexport-excel-macros","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrhanKupusoglu%2Fexport-excel-macros/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrhanKupusoglu%2Fexport-excel-macros/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrhanKupusoglu%2Fexport-excel-macros/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OrhanKupusoglu","download_url":"https://codeload.github.com/OrhanKupusoglu/export-excel-macros/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrhanKupusoglu%2Fexport-excel-macros/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32377599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T09:24:15.638Z","status":"ssl_error","status_checked_at":"2026-04-28T09:24:15.071Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["git","ms-excel","pre-commit-hook","workbook","worksheet"],"created_at":"2024-11-05T19:07:32.310Z","updated_at":"2026-04-28T11:01:49.910Z","avatar_url":"https://github.com/OrhanKupusoglu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Export MS Excel Macros\r\n\r\nSince [MS Excel](https://en.wikipedia.org/wiki/Microsoft_Excel) workbooks are binary file formats, they are not suitable for revision control.\r\n\r\nAn MS Excel workbook containing macros, if added to [Git](https://en.wikipedia.org/wiki/Git), should be able to export all the source codes with each commit.\r\n\r\n\u0026nbsp;\r\n\r\n## Requirement\r\n\r\nThe Python tool [oletools](https://pypi.org/project/oletools/) is required to export the contained VBA forms \u0026 modules:\r\n\r\n```\r\n\u003epip install -U oletools\r\n```\r\n\r\n\u0026nbsp;\r\n\r\n## Git Hooks\r\n\r\nThe [Pro Git book](https://git-scm.com/book/en/v2) explains [Git Hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) in great detail:\r\n\r\n\u003e Like many other Version Control Systems, Git has a way to fire off custom scripts when certain important actions occur.\r\n\r\nA [Bash script](./pre-commit/pre-commit) and a [Python script](./pre-commit/pre-commit.py) together export macros contained in MS Excel workbooks.\r\n\r\nThese scripts are tested only on MS Windows.\r\n\r\n\u0026nbsp;\r\n\r\n## Pre-Commit Hook\r\n\r\nA **pre-commit** [hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) checks first for presence of unwanted worksheets. If such a worksheet is not present, then the pre-commit hook exports VBA modules to **src.vba** directory, so that all source files can be put under revision control.\r\n\r\nThe pre-commit hook script is taken from the blog post [How to use Git hooks to version-control your Excel VBA code](https://www.xltrail.com/blog/auto-export-vba-commit-hook).\r\nThe scripts are modified slightly.\r\n\r\nThe same company's open source [git-xl](https://github.com/xlwings/git-xl) extension for Git handles direct diff ops between workbook revisions, but it is not much of help inside an IDE.\r\n\r\nThese two files must first be put into the **.git/hooks** directory of the repository where workbooks are located.\r\n\r\n\u0026nbsp;\r\n\r\n## Filter Worksheets\r\n\r\nThe shell script can give an *unwanted* worksheet name.\r\nIf it is empty filtering is ignored.\r\n\r\n```\r\nWS_UNWANTED='Confidential'\r\n```\r\n\r\nA worksheet with exactly this name or containing this name causes the commit to fail.\r\nThe Python script may check for exact matches, by default a partial match filters unwanted worksheets.\r\n\r\n```\r\nEXACT_MATCH = False\r\n```\r\n\r\n\u0026nbsp;\r\n\r\n## Example\r\n\r\nAfter first copying the pre-commit hook scripts, an MS Excel file containing two VBA modules is added to the test repository:\r\n\r\n```\r\n\u003eTREE /F\r\nFolder PATH listing for volume Windows\r\nVolume serial number is EX47-DA1E\r\nC:.\r\n    LICENSE\r\n    README.md\r\n\r\nNo subfolders exist\r\n\r\n\u003eCOPY ..\\export-excel-macros\\pre-commit\\* .git\\hooks\r\n..\\export-excel-macros\\pre-commit\\pre-commit\r\n..\\export-excel-macros\\pre-commit\\pre-commit.py\r\n        2 file(s) copied.\r\n\r\n\u003eMKDIR workbook\r\n\r\n\u003eMOVE ..\\test.xlsm workbook\\.\r\n        1 file(s) moved.\r\n\r\n\u003egit status\r\nOn branch main\r\nUntracked files:\r\n  (use \"git add \u003cfile\u003e...\" to include in what will be committed)\r\n        workbook/\r\n\r\nnothing added to commit but untracked files present (use \"git add\" to track)\r\n\r\n\u003egit add workbook\r\n\r\n\u003egit commit -m \"Add a macro-containing MS Excel workbook\"\r\n[main 93d90d4] Add a macro-containing MS Excel workbook\r\n 3 files changed, 2174 insertions(+)\r\n create mode 100644 src.vba/Calculations.bas\r\n create mode 100644 src.vba/Init.bas\r\n create mode 100644 workbook/test.xlsm\r\n\r\n\u003egit status\r\nOn branch main\r\nnothing to commit, working tree clean\r\n\r\n\u003eTREE /F\r\nFolder PATH listing for volume Windows\r\nVolume serial number is EX47-DA1E\r\nC:.\r\n│   LICENSE\r\n│   README.md\r\n│\r\n├───src.vba\r\n│       Calculations.bas\r\n│       Init.bas\r\n│\r\n└───workbook\r\n        test.xlsm\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forhankupusoglu%2Fexport-excel-macros","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forhankupusoglu%2Fexport-excel-macros","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forhankupusoglu%2Fexport-excel-macros/lists"}