Exporting all Visio code from documents

Started by Abeiis, May 11, 2017, 07:52:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Abeiis

Hi ALL,
It may have been asked before, but to save time, I wonder if anyone came up with a macro/VBA that will look into a folder and export all VBA code per file name for all Visio files in a specific folder, Thanks!

Regards,
Abe

Nikolay

#1
I have written an Visio addin awhile ago to do that (but per-file):
http://unmanagedvisio.com/products/vba-importexport-addin/

The tool includes command-line utility as well, so you can do export with powershell script or a batch file (for batch processing of files).
You need MSI version: http://unmanagedvisio.com/download/vba_importexport/VisioImportExportVba.msi

The soruce code is avaialble here:
https://github.com/nbelyh/VisioImportExportVba

Nikolay

#2
I've added the documentation on command-line API here (see "Command Line API"):
http://unmanagedvisio.com/products/vba-importexport-addin/

Basically that is:

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.

Abeiis

Thank You Niikolay,

This will help greatly  8)