top of page

Syncing a VBA Project with a file(s) ... manually

  • Writer: John
    John
  • 3 days ago
  • 2 min read

For an entire VBA Project


When using VBE_Extras, you can right-click on a Project name in the VBE's Project window and select "Extras" > "Load from / save as files" > "Load Project from files" then select a folder and you can load an entire VBA Project's worth of Modules (code, attributes and UI elements of UserForms) from the files in that folder.


You'll have the option to either:

  • Update existing Modules and add new Modules only, or

  • Update existing Modules and add new Modules and remove Modules (i.e. Modules that do not have a file in the folder) ... a real "sync"


If working in Access, Forms and Reports will be added and removed where appropriate. In any other host application, Document Modules (ThisWorkbook and Sheets in Excel, ThisDocument in Word etc) cannot be added or removed but the VBA code and attributes will be updated to align with the contents of the files in the folder.


When loading an entire Project in this way, you will always first be shown a "diff report" of which Modules will be added, updated and (if appropriate) removed ... from which you can drill down to changes within individual procedures (or the Module declaration lines, or attributes) ... from which you can view individual changes line-by-line and character-by-character (see the Version Control for VBA post for details). You can then decide whether to proceed with loading or not.


Module diff example
Diff report for a procedure

There is also, of course, the reverse functionality ... right-click on a Project name in the VBE's Project window and select "Extras" > "Load from / save as files" > "Save Project as files" then select a folder and you can save an entire VBA Project's worth of Modules (again: code, attributes and UI elements of UserForms) as files in the selected folder.


For an individual Module


As well as the ability to do this for an entire Project's worth of Modules, you can do the same for individual Modules: right-click on a Module name in the VBE's Project window and select "Extras" > "Load from / save as files" then you will have the choice of:

  • Load this Module

  • Load new Module

  • Save this Module


When selecting "Load this Module", you'll be shown the "diff report", as noted above, but this time the diff report will show the changes only for the specific Module ... that is, changes within individual procedures and / or changes in the Module header lines and / or attributes.


And when selecting "Load new Module", you'll be shown the attributes and code of the Module before it is loaded so that you can confirm you have identified the correct files and that you want to proceed.

Comments


bottom of page