Export all masters to jpg

P

Phonebox

I want to export a large selection of masters to individual jpg's, but when I
select the masters and choose save as, I get error 920. Suggestions?
 
J

J Kallay

Unless I'm mistaken, "save as" will only save an entire Visio document or
stencil as a JPG. You might find it easier to drag a instance onto the
drawing page and then copy and paste into Paint (which is better suited for
working with bitmap images). Alternatively, the Master object has an Export
method, so with a very small amount of VBA code you could export all of the
masters in a stencil to JPGs by running a single macro.
 
P

Paul Herber

Unless I'm mistaken, "save as" will only save an entire Visio document or
stencil as a JPG.

Except, the saveAs will also save just the selected items. Also JPG
may not be the best format as it was designed for use with
photographs. GIF, PNG or WMF/EMF may be better.
 
P

Phonebox

Thank you very much for your answer. This is how I solved it. (If anyone have
the problem as I had). Place all masters you want to export onto a drawing
and execute the macro. Replace the output catalog with another one if
desired. The macro also ensures that the masters are the same size when
exported.

Sub Exportmacro()
Dim OldLenght, OldHeight, NewLenght, NewHeight, ScaleXY As Double

For Counter = 1 To 100000
OldLenght =
Application.ActiveWindow.Page.Shapes.ItemFromID(Counter).CellsSRC(visSectionObject, visRowXFormOut, visXFormWidth).FormulaU
If OldLenght = "" Then End
OldHeight =
Application.ActiveWindow.Page.Shapes.ItemFromID(Counter).CellsSRC(visSectionObject, visRowXFormOut, visXFormHeight).FormulaU
OldLenght = Val(Left$(OldLenght, Len(OldLenght) - 3))
If OldLenght = 0 Then End
OldHeight = Val(Left$(OldHeight, Len(OldHeight) - 3))
ScaleXY = OldLenght / OldHeight

If ScaleXY > 1 Then
NewLenght = 100
NewHeight = 100 / ScaleXY
Else
NewHeight = 100
NewLenght = 100 * ScaleXY
End If


Application.ActiveWindow.Page.Shapes.ItemFromID(Counter).CellsSRC(visSectionObject, visRowXFormOut, visXFormWidth).FormulaU = Str$(NewLenght) + " mm"

Application.ActiveWindow.Page.Shapes.ItemFromID(Counter).CellsSRC(visSectionObject, visRowXFormOut, visXFormHeight).FormulaU = Str$(NewHeight) + " mm"

Application.ActiveWindow.Page.Shapes.ItemFromID(Counter).Export
"C:\ExportedMasters\Master" + Str$(Counter) + ".jpg"

Next Counter

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top