다음을 통해 공유


프로그래밍 방식으로 문서 인쇄

전체 Microsoft Office Word 문서 또는 일부 문서를 기본 프린터에 인쇄할 수 있습니다.

적용 대상: 이 항목의 정보는 Word의 문서 수준 프로젝트 및 VSTO 추가 기능 프로젝트에 적용됩니다. 자세한 내용은 Office 애플리케이션 및 프로젝트 형식에 따라 사용 가능한 기능을 참조하세요.

전체 문서를 인쇄하려면

  1. 프로젝트의 PrintOut 클래스의 ThisDocument 메서드를 호출하여 전체 문서를 인쇄합니다. 이 예제를 사용하려면 ThisDocument 클래스에서 코드를 실행합니다.

    object copies = "1";
    object pages = "";
    object range = Word.WdPrintOutRange.wdPrintAllDocument;
    object items = Word.WdPrintOutItem.wdPrintDocumentContent;
    object pageType = Word.WdPrintOutPages.wdPrintAllPages;
    object oTrue = true;
    object oFalse = false;
    
    this.PrintOut(ref oTrue, ref oFalse, ref range, ref missing, ref missing, ref missing,
        ref items, ref copies, ref pages, ref pageType, ref oFalse, ref oTrue, 
        ref missing, ref oFalse, ref missing, ref missing, ref missing, ref missing);
    

문서의 현재 페이지를 인쇄하려면

  1. 프로젝트의 PrintOut 클래스의 ThisDocument 메서드를 호출하고 현재 페이지의 복사본 하나를 인쇄하도록 지정합니다. 이 예제를 사용하려면 ThisDocument 클래스에서 코드를 실행합니다.

    object copies = "1"; 
    object pages = "1"; 
    object range = Word.WdPrintOutRange.wdPrintCurrentPage; 
    object items = Word.WdPrintOutItem.wdPrintDocumentContent; 
    object pageType = Word.WdPrintOutPages.wdPrintAllPages; 
    object oTrue = true; 
    object oFalse = false; 
    
    this.PrintOut(
        ref oTrue, ref oFalse, ref range, ref missing, ref missing, ref missing,
        ref items, ref copies, ref pages, ref pageType, ref oFalse, ref oTrue, 
        ref missing, ref oFalse, ref missing, ref missing, ref missing, ref missing);
    

전체 문서를 인쇄하려면

  1. 인쇄하려는 PrintOut 개체의 Document 메서드를 호출합니다. 다음 코드 예제에서는 활성 문서를 인쇄합니다. 이 예제를 사용하려면 프로젝트의 ThisAddIn 클래스에서 코드를 실행합니다.

    this.Application.ActiveDocument.PrintOut(true, false, Word.WdPrintOutRange.wdPrintAllDocument,
        Item: Word.WdPrintOutItem.wdPrintDocumentContent, Copies:"1", Pages:"", 
        PageType:Word.WdPrintOutPages.wdPrintAllPages, PrintToFile:false, Collate:true,
        ManualDuplexPrint:false);
    

문서의 현재 페이지를 인쇄하려면

  1. 인쇄하려는 PrintOut 개체의 Document 메서드를 호출하고 현재 페이지의 복사본 하나를 인쇄하도록 지정합니다. 다음 코드 예제에서는 활성 문서를 인쇄합니다. 이 예제를 사용하려면 프로젝트의 ThisAddIn 클래스에서 코드를 실행합니다.

    object copies = "1";
    object pages = "1";
    object range = Word.WdPrintOutRange.wdPrintCurrentPage;
    object items = Word.WdPrintOutItem.wdPrintDocumentContent;
    object pageType = Word.WdPrintOutPages.wdPrintAllPages;
    object oTrue = true;
    object oFalse = false;
    Word.Document document = this.Application.ActiveDocument;
    
    document.PrintOut(
        ref oTrue, ref oFalse, ref range, ref missing, ref missing, ref missing,
        ref items, ref copies, ref pages, ref pageType, ref oFalse, ref oTrue,
        ref missing, ref oFalse, ref missing, ref missing, ref missing, ref missing);