excel -- where are macros stored in the object model? (I want to back them up)

Christian Bahnsen -- .mil account 201 Reputation points
2020-12-30T17:36:50.51+00:00

We've been going through some enterprise-wide "upgrades" and I'm currently unable to run macros. I can open Visual Basic and see the modules, but I can't run them. I want to make backups of the macros before they get zapped by a group policy.

I looked at the excel object model but I don't see a "macros" object. Ideally, I'd like to iterate through the modules and write the contents of each to a text file for backup purposes.

I guess I could open each module manually, Select All, Copy, and paste to a text file, but I'd rather automate the process if I can.

So where are macros stored in the object model?

The macros are stored locally in each workbook, as opposed to in Personal.xlsb

I'm planning to use PowerShell to automate the process

Thanks for any assistance.

Christian Bahnsen

Developer technologies | Visual Basic for Applications
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    2020-12-30T18:54:51.493+00:00

    This one may sort it.
    https://gist.github.com/atifaziz/8819159

    --please don't forget to Accept as answer if the reply is helpful--


  2. Richard Michaels 126 Reputation points
    2020-12-31T18:38:21.23+00:00

    Take a look at this page on Ron de Bruin’s Excel automation website. It should give you the information you need, at least for having it automated by VBA.

    https://www.rondebruin.nl/win/s9/win002.htm

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.