Bagikan melalui


How to: Programmatically Print Visio Documents

You can print a complete Microsoft Office Visio document or only a specific page.

For details about the print methods, see the VBA reference documentation for the Microsoft.Office.Interop.Visio.Document.Print method and Microsoft.Office.Interop.Visio.Page.Print method.

Printing a Visio Document

To print a complete document

  • Call the Microsoft.Office.Interop.Visio.Document.Print method of the Microsoft.Office.Interop.Visio.Document object that you want to print.

    The following code example prints the active document. To use this example, run the code from the ThisAddIn class in your project.

    Me.Application.ActiveDocument.Print()
    
    this.Application.ActiveDocument.Print();
    

Printing a Page of a Visio Document

To print a page of a document

  • Call the Microsoft.Office.Interop.Visio.Pages.Print method of the Microsoft.Office.Interop.Visio.Pages object that you want to print.

    The following code example prints the first page of the active document. To use this example, run the code from the ThisAddIn class in your project.

    Dim pageIndex As Integer = 1
    Dim visioDocPages As Visio.Pages = Me.Application.ActiveDocument.Pages
    If pageIndex <= visioDocPages.Count Then
        visioDocPages(pageIndex).Print()
    End If
    
    int pageIndex = 1;
    Visio.Pages visioDocPages = this.Application.ActiveDocument.Pages;
    if (pageIndex <= visioDocPages.Count)
        visioDocPages[pageIndex].Print();
    

See Also

Tasks

How to: Programmatically Create New Visio Documents

How to: Programmatically Open Visio Documents

How to: Programmatically Close Visio Documents

How to: Programmatically Save Visio Documents

Concepts

Visio Object Model Overview

Other Resources

Visio Solutions