- Utwórz nowy folder, w którym będą się znajdować tylko pliki MS Word, które chcesz wydrukować
- Utwórz nowy plik MS Word
- Otwórz okno Visual Basic
- Z górej wstążki wybierz
Insert->Module - Przeklej kod ponizej do okna VBA
- Uruchom skrypt
Last active
May 31, 2021 14:47
-
-
Save hylickipiotr/865ef127bdd4534606d9ca5c3b68c7a7 to your computer and use it in GitHub Desktop.
Print multiple MS Word documents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sub BatchPrintWordDocuments() | |
| Dim objWordApplication As New Word.Application | |
| Dim strFile As String | |
| Dim strFolder As String | |
| On Error GoTo Err | |
| strFolder = InputBox("Podaj ścieżkę do folderu", "Ścieżka folderu") | |
| If Not Right(strFolder, 1) = "\" Then | |
| strFolder = strFolder & "\" | |
| End If | |
| strCopiesCount = InputBox("Ilość kopii", "Ilość kopii", "1") | |
| strFile = Dir(strFolder & "*.doc*", vbNormal) | |
| copiesCount = Int(strCopiesCount) | |
| While strFile <> "" | |
| With objWordApplication | |
| .Documents.Open (strFolder & strFile) | |
| .ActiveDocument.PrintOut Copies:=copiesCount, ManualDuplexPrint:=False | |
| .ActiveDocument.Close | |
| End With | |
| strFile = Dir() | |
| Wend | |
| Set objWordApplication = Nothing | |
| MsgBox "Wszystkie pliki zostały przekazane do druku. Możesz już bezpiecznie zamknąć Word'a." | |
| Exit Sub | |
| Err: | |
| MsgBox "Coś poszło nie tak. Spróbuj ponownie" | |
| End Sub | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment