How can I expose Word VBA macro code as text files in VSC to better commit and track code changes?

300 Views Asked by At

Background and Problem

I lead a team of tech writers. Our team has a Word template (.dotm file) that has a bunch of VBA macros we've created over the years to help us automate tasks in Word. The macros are obviously stored inside of a .dotm template. Given that the code is stored in a binary file, the code is not easily traceable across commits.

Currently, we have to pull the changes on the branch and then open the macro inside Word's embedded code editor from the .dotm. But there's no way to see what exact code changes someone else made line by line or resolve conflicts using something like Beyond Compare.

What I Need

I'd like to find a way to automatically expose the VBA code from the .dotm as some kind of text file so that we can:

  • Do Word VBA coding tasks within VSC
  • Easily track and review each others code changes at the line level using our git repository
  • Resolve merge conflicts more easily

Has anyone found a way to do this?

What I've tried

Thank you in advance!

1

There are 1 best solutions below

0
Eugene Astafiev On

ScriptLab add-on is for playing with JavaScript code instantly, not designed as a macro infrastructure in Office.

Sounds like you need to switch your VBA macros to COM add-ins rails. There is no converters that can do this part of work for you automatically.

You may consider creating a VB.NET based add-in. In that case you will avoid language translating issues. You may find the Converting Code from VBA to Visual Basic .NET article helpful. It presents issues to consider when converting your Microsoft Office solutions from Visual Basic for Applications (VBA) to Visual Basic .NET. Provides a general overview of their differences, and then uses examples from Word and Excel to describe how you can use Visual Studio Tools for the Microsoft Office System to convert your code.