Macro hiding Visio layers before printing

M

Mike Stockman

I'm having some trouble programmatically hiding layers before printing a
Visio document. I have a .VBS macro that opens a Visio document, prints it to
a Postscript file, then runs distiller on the results. (The bulk of this
macro is shamelessly stolen for my own internal use from Michael Sudenjoki's
excellent doc2pdf.vbs macro at
<http://www.suodenjoki.dk/us/productions/articles/word2pdf.htm>.)

Anyway, the problem is that although I can loop through the list of layers,
identify them by name, and hide the ones I want from printing, they print
anyway. Here's the relevant code:

' Open the Visio document
Set wdoc = wdocs.Open(sVSDFile)

' Show only the requested layer
Set vsoPage = wdoc.Pages(1)
'Get the Layers collection.
Set vsoLayers = vsoPage.Layers
For Each layerList In vsoLayers
If layerList = "foo" Then
layerList.CellsC(visLayerPrint).FormulaU = 0
End If
If layerList = "bar" Then
layerList.CellsC(visLayerPrint).FormulaU = 1
End If
Next

' Print the Visio document to the Acrobat Distiller -
' will generate a postscript (.ps) (temporary) file
wdo.ActiveDocument.PrintOut visPrintAll , , , , , true , sTempFile

Can anyone tell me why this isn't working? I'm not seeing any errors -- just
a failure to do what I'm requesting.

Thanks,
Mike
 

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