I am trying to export pages to PNG from Visio, in high resolution.
When I export manually with a custom resolution of 300x300, I get dimensions of 3450x2397.
When I export with VBA with the syntax below, I get dimensions of 1104x767.
Where is the hitch? In the Application.Settings lines, I started out with just the first line, then added the others later, but it still does not work.
Edit: what is particularly infuriating is that this used to work. I even fetched an older version of the macro file from git, that I generated hi-res images with, and now they produce normal res images (3 figures instead of 4 in the dimensions).
...
pngPathName = pngPath & "\" & visioPage.name & ".png"
Debug.Print ("visioPage.Export " + pngPathName)
' set resolution to 300dpi
Application.Settings.SetRasterExportResolution visRasterUseCustomResolution, 300#, 300#, visRasterPixelsPerInch
Application.Settings.SetRasterExportSize visRasterFitToSourceSize, 2.208333, 2.135417, visRasterInch
Application.Settings.RasterExportDataFormat = visRasterInterlace
Application.Settings.RasterExportColorFormat = visRaster24Bit
Application.Settings.RasterExportRotation = visRasterNoRotation
Application.Settings.RasterExportFlip = visRasterNoFlip
' Export the page as an PNG file
visioPage.Export pngPathName
...
It turns out that Application and visioPage weren't on the same page. Application was referring to the file where the macro is located, visioPage to the file I was saving as PNG. This is inside a loop where I was processing all the files in a folder.
This is what I did to solve the problem:
So I guess the moral is, in Visio VBA, to beware of the Application object, particularly when copy-pasting lines of code from the Macro recorder.