Untitled

 avatar
unknown
plain_text
5 months ago
801 B
4
Indexable
Sub PrintMultipleWordDocs()
    Dim FilePath As String
    Dim FileName As String
    Dim doc As Document
    
    ' Okno wyboru folderu z plikami
    With Application.FileDialog(msoFileDialogFolderPicker)
        .Title = "Wybierz folder z dokumentami"
        If .Show = -1 Then
            FilePath = .SelectedItems(1) & "\"
        Else
            MsgBox "Nie wybrano folderu!"
            Exit Sub
        End If
    End With
    
    ' Przechodzi przez wszystkie pliki .docx w folderze
    FileName = Dir(FilePath & "*.docx")
    While FileName <> ""
        Set doc = Documents.Open(FilePath & FileName)
        doc.PrintOut ' Drukowanie dokumentu
        doc.Close SaveChanges:=wdDoNotSaveChanges
        FileName = Dir
    Wend
    
    MsgBox "Wszystkie pliki zostały wydrukowane."
End Sub
Editor is loading...
Leave a Comment