HTML Export API

The HTML Export plugin supports automation API (can be called programmatically). This allows you to execute export with code. The addin can be called from any language that supports automation, including in particular Visio VBA itself, .NET languages, Powershell. Basically, if you can call Visio API, you should be also able to call the plugin API. The type library is installed with the addin (it is called GenerateVisioSvg), and you can use it to add a reference to your project for autocomplete. With API, you can:

  • Get/Set any export parameters
  • Export to disk, sharepoint, github

You can check out the full API Reference

Getting the Addin from Visio

To get the addin API, you need to query Visio COMAddins collection by name SvgExport. This provides the SvgPublishApi

Set addin = Application.COMAddIns("SvgExport").Object

Getting current document publishing options

To get the options configured for the document using current UI, you can use GetPublishOptions:

Set addin = Application.COMAddIns("SvgExport").Object
Set opts = addin.GetPublishOptions(ActiveDocument)

Updating current document publishing options

To update the options configured for the document using current UI, you can use SetPublishOptions. Please note that the options are saved in the document (SolutionXmlData). So you need to save the document to save the options.

Set addin = Application.COMAddIns("SvgExport").Object
Set opts = addin.GetPublishOptions(ActiveDocument)
opts.FileName = foo.html addin.SetPublishOptions(ActiveDocument, opts)

Exporting to disk

The disk export requires you to set Disk BasePath option (where the fiel will be written) and the FileName – the name of the export file. Set SupportFiles to deploy to include support files (can be ommited, if they were already published before to the target location). The ExportToDisk method executes the export of the given document.

Sub My()
	Set addin = Application.COMAddIns("SvgExport").Object
	Set opts = addin.GetPublishOptions(ActiveDocument)
	opts.FileName = "myexport.html"
	opts.SupportFiles = SupportFilesOption_Deploy
	opts.Disk.BasePath = "c:\\some\\folder"
	URL = addin.ExportToDisk(ActiveDocument, opts)
End Sub

Exporting to SharePoint

The SharePoint export requires you to specify target site, file name, and your credentials. You can optionally also specify the SupportFiles option, and other share point settings. For the full list of options, please check out the API reference. The method ExportToSharePoint executes the export of the given document.

Sub My()
	Set api = Application.COMAddIns("SvgExport").Object
	Set opt = api.GetPublishOptions(ActiveDocument) 
	opt.FileName = "myexport.html"
	opt.SharePoint.SiteUrl = "https://mysite.sharepoint.com"
	opt.SharePoint.UserName = "mylogin@mysite.onmicrosoft.com"
	opt.SharePoint.Password = "my@password"
	opt.SharePoint.AuthenticationMode = AuthenticationMode_SharePointOnline
	URL = api.ExportToSharePoint(ActiveDocument, opt)
End Sub

Exporting to GitHub

The GitHub export requires you to specify target repository, file name, and hosting service (by default, github pages will be used). Now, you need to be logged in for the export to work. Also please notice taht rawgit option produces one-time links. See ExportToGitHub for the details.

Sub My()
	Set addin = Application.COMAddIns("SvgExport").Object
	Set opt = addin.GetPublishOptions(ActiveDocument) 
	opt.FileName = "myexport.html"
	opt.SupportFiles = SupportFilesOption_Deploy
	opt.GitHub.GitHubRepositoryName = test
	opt.GitHub.GitHubUseRawGit = True
	URL = addin.ExportToGitHub(ActiveDocument, opt)
End Sub