-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprinter.py
More file actions
32 lines (30 loc) · 951 Bytes
/
printer.py
File metadata and controls
32 lines (30 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import time
from win32com import client
from filemanagement import ClassFile
class doc:
def printwordDocument(self,folder,filename):
os.path.join(os.getcwd(), folder, filename)
word = client.DispatchEx("word.Application")
word.Visible = False
filename = os.path.abspath(filename)
word.Documents.Open(filename)
word.ActiveDocument.PrintOut()
time.sleep(2)
word.ActiveDocument.Close()
word.Quit()
return
def printing(folder):
filelist = [x for x in
os.listdir(folder) if x.endswith('docx')]
for filename in filelist:
inst = doc()
i = os.path.abspath(folder) +"\\"+ filename
try:
inst.printwordDocument(folder,i)
except:
pass
del_obj = ClassFile()
del_obj.delete_all_files_by_extension(folder,"docx")
return
#printing("letters")