Command line to import/export Visio VBA code

The import/export VBA extension supports not only the UI (button-click), but also command line interface!

It was not initially documented (now it is), but the tool includes command-line utility as well, so that one can use it with powershell script or a batch file (for batch processing of files), or in any other automated way. For this functionality MSI (full) version is required:  VisioImportExportVba-1.0.3.msi (912.0 KiB)

Below are some examples of what can be done using command line.

To extract all code from a single Visio file to current folder:

vba_import_export.exe export C:\MyVsiioFiles\MyFile.vsd

 

To extract all code from a single Visio file to a specified folder:

vba_import_export.exe export C:\MyVsiioFiles\MyFile.vsd -o C:\TragetFolder

 

To import all code back to a single Visio file from current folder:

vba_import_export.exe import C:\MyVsiioFiles\MyFile.vsd

 

To import all code back to a single Visio file from a specified folder:

vba_import_export.exe import C:\MyVsiioFiles\MyFile.vsd -i C:\TragetFolder

 

To process all files in specified folder (powershell):

foreach ($file in Get-ChildItem "C:\MyVisioDocuments\*.vsd")
{
  &vba_import_export.exe export $file.FullName -o C:\MyVisioDocuments\$($file.Name).exported
}

 

To import all code back:

foreach ($file in Get-ChildItem "C:\MyVisioDocuments\*.vsd")
{
  &vba_import_export.exe import $file.FullName -i C:\MyVisioDocuments\$($file.Name).exported
}

 

To import all back from a fixed specific folder, and overwrite everything.

foreach ($file in Get-ChildItem "C:\MyVisioDocuments\*.vsd")
{
  &vba_import_export.exe import $file.FullName -i C:\VbaCodeVersion2 -c
}

This one one can be useful in scenarios, when you need to update your app code in multiple user files to a “new” version.
Another solution to update vba code could to keep the code in stencils, and just update stencil, but sometimes it’s just not feasible.

Leave a Reply