K
K. Chen
hi, all, I'm trying to automate the process to export some Visio
diagrams HTML format. The VBA program works ok, but the output is
somewhat different to the result produced when you do SaveAs HTML in
Visio. When using VBA, it produced a pulldown menu at the bottom right
with a list of display sized, default being "Fit on Screen", this is
normally too small to see comfortably and needs resizing, which is
painful when you have to do it for every page.
When I do a SaveAs HTML, the output produced is the exact size as you
see in Visio, which is much more pleasant. Anybody has any idea on how
to produce this output? Following is the VBA function that produced
the output. I tried this in Visio 2000 SR1.
TIA
KC
Sub SaveAsHTML(pages As Visio.pages, htmlFolder As String, baseName As
String)
' error handler
On Error GoTo ErrorHandle
' get proper basename
baseName = Left(baseName, Len(baseName) - 4)
' Initialize the filters collection.
Dim flts As New Filters
Set flts.Parent = Visio.Application
' Get the Vector filter.
' VML, GIF, JPG, and PNG are valid options.
Dim fltVector As Filter
Set fltVector = flts.Item("VML")
' Get the Raster filter. Needed if the vector filter is VML.
' JPG and PNG are valid options.
Dim flt As Filter
Set flt = flts.Item("JPG")
'Set flt = flts.Item("GIF")
' initialize Utilities
Dim utils As New Utilities
' Initialize themes.
Dim thm As Theme
Dim thms As Themes
Set thms = utils.LoadThemes()
' Only one theme is available, "Default"
Set thm = thms.Item(1)
' Initialize export data.
Dim expData As New ExportData
' Set the VSD.
'expData.Document = Me.Name
expData.Document = htmlFolder & ".vsd"
' Set the vector filter.
Set expData.VMLFilter = fltVector
' Set the raster filter.
Set expData.Filter = flt
' Expose hyperlinks?
expData.ExposeHyperlinks = True
' set the map type, see constants above.
expData.MapType = visMapTypeClient
' if MapType is CGI...
expData.CGIMap = ""
' Set the theme.
Set expData.Theme = thm
' Set the output file name.
expData.BaseFileName = baseName & ".htm"
' Add a page.
'expData.pages.Add ActivePage.Name
Dim i As Integer
For i = 1 To pages.Count
expData.pages.Add pages(i)
Next i
' Initialize export manager.
Dim mgr As New ExportMgrDrawing
' Set the output folder.
mgr.OutputFolder = htmlFolder
' Set the export data.
Set mgr.ExportData = expData
' Perform the export.
mgr.Export Visio.Application
Exit Sub
ErrorHandle:
MsgBox "You raised error: " & _
Err & ", " & Err.Description & _
vbCrLf & _
"At program location: " & _
Err.Source
End Sub
diagrams HTML format. The VBA program works ok, but the output is
somewhat different to the result produced when you do SaveAs HTML in
Visio. When using VBA, it produced a pulldown menu at the bottom right
with a list of display sized, default being "Fit on Screen", this is
normally too small to see comfortably and needs resizing, which is
painful when you have to do it for every page.
When I do a SaveAs HTML, the output produced is the exact size as you
see in Visio, which is much more pleasant. Anybody has any idea on how
to produce this output? Following is the VBA function that produced
the output. I tried this in Visio 2000 SR1.
TIA
KC
Sub SaveAsHTML(pages As Visio.pages, htmlFolder As String, baseName As
String)
' error handler
On Error GoTo ErrorHandle
' get proper basename
baseName = Left(baseName, Len(baseName) - 4)
' Initialize the filters collection.
Dim flts As New Filters
Set flts.Parent = Visio.Application
' Get the Vector filter.
' VML, GIF, JPG, and PNG are valid options.
Dim fltVector As Filter
Set fltVector = flts.Item("VML")
' Get the Raster filter. Needed if the vector filter is VML.
' JPG and PNG are valid options.
Dim flt As Filter
Set flt = flts.Item("JPG")
'Set flt = flts.Item("GIF")
' initialize Utilities
Dim utils As New Utilities
' Initialize themes.
Dim thm As Theme
Dim thms As Themes
Set thms = utils.LoadThemes()
' Only one theme is available, "Default"
Set thm = thms.Item(1)
' Initialize export data.
Dim expData As New ExportData
' Set the VSD.
'expData.Document = Me.Name
expData.Document = htmlFolder & ".vsd"
' Set the vector filter.
Set expData.VMLFilter = fltVector
' Set the raster filter.
Set expData.Filter = flt
' Expose hyperlinks?
expData.ExposeHyperlinks = True
' set the map type, see constants above.
expData.MapType = visMapTypeClient
' if MapType is CGI...
expData.CGIMap = ""
' Set the theme.
Set expData.Theme = thm
' Set the output file name.
expData.BaseFileName = baseName & ".htm"
' Add a page.
'expData.pages.Add ActivePage.Name
Dim i As Integer
For i = 1 To pages.Count
expData.pages.Add pages(i)
Next i
' Initialize export manager.
Dim mgr As New ExportMgrDrawing
' Set the output folder.
mgr.OutputFolder = htmlFolder
' Set the export data.
Set mgr.ExportData = expData
' Perform the export.
mgr.Export Visio.Application
Exit Sub
ErrorHandle:
MsgBox "You raised error: " & _
Err & ", " & Err.Description & _
vbCrLf & _
"At program location: " & _
Err.Source
End Sub