본문 바로가기
엑셀

폴더안에 있는 워드 일괄 출력하는 매크로

by 델피1004 2025. 10. 29.
반응형

Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal Milliseconds As LongPtr)

Sub BatchPrintWordDocuments()
Dim objWordApplication As New Word.Application
Dim strFile As String
Dim strFolder As String


strFolder = InputBox("폴더 주소 입력", "폴더 주소", "D:\temp\")

'strFolder = "D:\temp\"
strFile = Dir(strFolder & "*.docx", vbNormal)


While strFile <> ""
With objWordApplication
    .Documents.Open (strFolder & strFile)
    .ActiveDocument.PrintOut
    .ActiveDocument.Close
    End With
    
    'Application.Wait (Now + TimeValue("0:00:30"))
    Sleep (10000)
    
    strFile = Dir()
Wend

Set objWordApplication = Nothing




End Sub

반응형

댓글