Click or drag to resize

Getting Started with API

To use the addin you need to get it from Visio, and the call it's functions. All parameters that are available on UI are accessibel through the API as well. The publishing options can be set by passing to the publishing method an IPublishOptions.

Getting the Addin from Visio

To get the addin API, you need to query Visio COMAddins collection by name "SvgExport". This provides a root API object as "addin", the ISvgPublishApi

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. The below sample exports to SharePoint Online site.

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