Microsoft KB Archive/300134

= Sample VBA macro to send a drawing to a specific printer in Visio =

Article ID: 300134

Article Last Modified on 11/28/2006

-

APPLIES TO


 * Microsoft Office Visio Professional 2007
 * Microsoft Office Visio Standard 2007
 * Microsoft Office Visio Professional 2003
 * Microsoft Office Visio Standard 2003
 * Microsoft Visio 2002 Professional Edition
 * Microsoft Visio 2002 Standard Edition

-



This article was previously published under Q300134



SUMMARY
This article contains a sample Microsoft Visual Basic for Applications macro to specify a printer or a plotter, and to send the drawing to that device.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Sample macro
The following sample Visual Basic macro for specifying a printer uses the PageSheet property of the Page object to switch the page width and height values. Public Sub PrintThisDoc 'Set up a dummy print object Dim docObj As Visio.Document Dim docObjTemp As Object Dim dummy As String Set docObj = ThisDocument Set docObjTemp = docObj ' The printer name must be spelled exactly ' as you find it in the printers list in the ' File/Print dialog box. ActiveDocument.Printer = &quot;MS Printer 350&quot; 'Send the document to the specified device dummy = docObjTemp.Print End Sub

